submitting of a form

Hello, I am trying to submitting my modelform and want to save as model in admin panel bu submit button just refreshes the page and nothing happens. i can save models from admin pannel manually but cannot this way. thank you :slight_smile:

views.py:

def toplant─▒Ekle(request):
    if request.method == "POST":
        form = Toplant─▒Olu┼čturmaForm(data=request.GET, files=request.FILES)
        if form.is_valid():
            yeni_toplant─▒ = form.save(commit=False)
            yeni_toplant─▒.user = request.user
            yeni_toplant─▒.save()
    else:
        form = Toplant─▒Olu┼čturmaForm(data=request.GET)
    return render( request, "toplant─▒app/toplant─▒ekle.html",{
        'form':form
    }) 

models.py:

class Toplant─▒Olu┼čturma(models.Model):
   
    
    user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    konu = models.CharField(max_length=100)
    tarih = models.DateTimeField(auto_now_add=True)
    kat─▒l─▒mc─▒ = models.CharField(max_length=50, blank=False)
    tgs_d─▒┼č─▒_kat─▒l─▒mc─▒ = models.CharField(max_length=50, blank=True)
    dosya_y├╝kle = models.FileField(upload_to='uploads/', blank=True)
    a├ž─▒klama = models.TextField(blank=True, max_length=5255)

    def __str__(self):
        return self.konu

forms.py:

class Toplant─▒Olu┼čturmaForm(forms.ModelForm):

    class Meta:
        model = Toplant─▒Olu┼čturma
        fields = '__all__'
        widgets = {
            'tarih':forms.DateInput(attrs={'type':'date'}),
            'a├ž─▒klama':forms.Textarea(attrs={'cols':50,'rows':35, 'placeholder':'A├ž─▒klama', 'style': 'width:100%; border: solid 1px gray'}),
        }
        labels = {
            'konu':'formkonu',
            'tarih':'tarih',
            'kat─▒l─▒mc─▒':'kat─▒l─▒mc─▒',
            'a├ž─▒klama':'a├ž─▒klama'
        }

and this is my template:

        <form method="POST" enctype="multipart/form-data">
            {% csrf_token %}
            <div class="card">
                <div class="container">
                    <div class="row justify-content-between">
                        <div class="col-5">
                            <input id="formkonu" class="konu" type="text" name="formkonu" value="{{formkonu}}" placeholder="Konu">
                            </br>
                            <input type="datetime" class="tarih" id="datepicker" placeholder="Tarih " value="{{tarih}}">
                            </br></br>
                            <div class="input-group" style="padding-right: 16%;">
                                <div id="├žal─▒┼čan" class="form-control select multiple" data-list="├žal─▒┼čanlar" style="width: 70%; border-radius: 0%; border: 1px solid gray; height: 45px;">
                                    <input id="├žal─▒┼čan_giri┼či" type="text" data-bs-toggle="dropdown" placeholder="├çal─▒┼čan" style="width: 50px;"/>
                                    <div class="dropdown-menu"></div>
                                    <select name="├žal─▒┼čan" multiple hidden>
                                        <option></option> <!--Kat─▒l─▒mc─▒ input arean─▒n b├╝y├╝memesini ├ž├Âz!!!-->
                                    </select>
                                </div>
                                <label style="padding: 3%;">
                                    <input class="mail1" type="checkbox" id="mail" name="mail"> Mail
                                </label>
                            </div>
                            <input id="tgs_d─▒┼č─▒_kat─▒l─▒mc─▒" class="tgs_d─▒┼č─▒_kat─▒l─▒mc─▒" type="text" name="tgs_d─▒┼č─▒_kat─▒l─▒mc─▒" value="{{ tgs_d─▒┼č─▒_kat─▒l─▒mc─▒ }}" placeholder="TGS D─▒┼č─▒ Kat─▒l─▒mc─▒lar">
                            <label style="margin-left: 8px;">
                                <input class="mail2" type="checkbox" id="mail" name="mail"> Mail
                            </label>
                            </br>
                            </br>
                            <input class="dosya_ekleme" id="dosya_ekleme" type="file" name="dosya_ekleme" value="{{dosya_ekleme}}" placeholder="Dosya Y├╝kle" style="display:none;">
                            <label for="dosya_ekleme" class="dosya_ekleme" style="color: gray;">Dosya Y├╝kle </label>
                        </div>
                        <div class="col-5">
                            {{form.a├ž─▒klama}}
                        </div>
                    </div>
                </div>
            </div>
            <input class="button" type="submit">
            <button class="button1" type="submit">Kaydet</button>
        </form>

Side note: When youÔÇÖre posting code (or templates) here, please enclose the code between lines of three backtick - ` characters. This means youÔÇÖll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted. (IÔÇÖve taken the liberty of editing your original post for this.)

1 Like

The submitted data on a POST is not in request.GET, itÔÇÖs in request.POST. (Also, itÔÇÖs customary to not specify the data= for that first parameter.)

And, as a side note:

Binding request.GET isnÔÇÖt necessary here.

1 Like