Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
ixnur committed Aug 18, 2023
1 parent a462770 commit c421339
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
8 changes: 8 additions & 0 deletions envanter/envanter/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django import forms
from .models import Component

class ComponentForm(forms.ModelForm):
class Meta:
model = Component
fields = ['category', 'model', 'manufacturer', 'stock', 'ohm', 'w', 'technical_specifications', 'picture_url', 'document_url']

3 changes: 2 additions & 1 deletion envanter/envanter/teplates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@

<div id="add-component-popup" class="popup">
<h2>Yeni Komponent Ekle</h2>
<form action="/parca_ekle" method="post">
<form action="{% url 'parca_ekle' %}" method="post">
{% csrf_token %}
<label for="kategori">Kategori:</label>
<select id="kategori" name="kategori" required>
Expand Down Expand Up @@ -191,6 +191,7 @@ <h2>Yeni Komponent Ekle</h2>





<footer>&copy; @mekatronik.org © 2023 Parça Envanteri Uygulaması.</footer>

Expand Down
2 changes: 2 additions & 0 deletions envanter/envanter/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@

urlpatterns = [
path('', views.index, name='index'),
path('parca_ekle', views.parca_ekle, name='parca_ekle'), # URL'yi doğru şekilde belirtin

]
13 changes: 12 additions & 1 deletion envanter/envanter/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
from django.shortcuts import render
from .models import Category, Component
from django.http import HttpResponse
from django.shortcuts import render, redirect
from .forms import ComponentForm


def parca_ekle(request):
if request.method == 'POST':
form = ComponentForm(request.POST)
if form.is_valid():
form.save()
return redirect('index')
else:
form = ComponentForm()
return render(request, 'index.html', {'form': form})

def Category

def index(request):
search_model = request.GET.get('search_model')
Expand Down

0 comments on commit c421339

Please sign in to comment.