Can't render django-countries-plus options in form template - python

For some reason I can't get the list of Countries in django-countries-plus to render in my template.
The table is imported fine under Countries Plus > Countries and I've set the models.py up as follows:
from countries_plus.models import Country
class Project(models.Model):
title = models.CharField(max_length=500)
status = models.BooleanField(default=True)
location = models.CharField(max_length=500)
projectcountry = models.ForeignKey(Country)
Then added the new field projectcountry to the form on forms.py:
from django.forms import ModelForm
from .models import Project, Proposal
class ProjectForm(ModelForm):
class Meta:
model = Project
fields = ['title', 'status', 'location', 'projectcountry']
Then in the template I'm trying to bring in the 252 countries in the table to render in a Bootstrap dropdown:
<form class="form-horizontal" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group">
<label class="col-sm-2 control-label">PROJECT TITLE</label>
<div class="col-sm-6">
<textarea rows="1" class="form-control" name="title"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">STATUS</label>
<div class="col-sm-6">
<select name="status" class="form-control">
<option value="1">Active</option>
<option value="0">Disabled</option>
</select>
</div>
<div class="col-sm-4">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">CITY / TOWN</label>
<div class="col-sm-6">
<textarea rows="1" class="form-control" name="location"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">COUNTRY</label>
<div class="col-sm-6">
<select name="projectcountry" class="form-control">
{% for country in countries %}
<option value="{{ country.iso }}">{{ country.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-sm-4">
</div>
</div>
</form>
Can you see what I'm doing wrong? I've been struggling with this researching all day but not cracked it.

Related

Not able send data to the database in Django

I wanna create a appointment system but its not working now. I'dont have a error actually i just have a error and it's coming from views.py (messages.warning(request,"ERROR!")). When i opened the page its coming anyway i just wanna send my informations.
models.py: I created models but im not sure for policlinic and doctor because it doesn't seems like charfield text. It's a option field in HTML.
class Randevu(models.Model):
STATUS = (
('New', 'Yeni'),
('True', 'Evet'),
('False', 'Hayır'),
)
policlinic=models.ForeignKey(Policlinic,on_delete=models.CASCADE)
user=models.ForeignKey(User,on_delete=models.CASCADE)
doctor=models.ForeignKey(Doctors,on_delete=models.CASCADE)
phone = models.CharField(max_length=15)
email = models.CharField(max_length=50)
date=models.DateField(null=True)
time=models.TimeField(null=True)
payment= models.CharField(max_length=50)
insurance= models.CharField(max_length=50)
note=models.TextField(max_length=200)
status = models.CharField(max_length=10, choices=STATUS,default='New')
ip=models.CharField(max_length=20,blank=True)
create_at = models.DateTimeField(auto_now_add=True)
update_at = models.DateTimeField(auto_now=True)
def str(self):
return self.user.username
class AppointmentForm(ModelForm):
class Meta:
model=Randevu
fields=['phone','email','date','time','payment','insurance','note']
views.py:
def randevu(request):
setting=Setting.objects.get(pk=1)
policlinic=Policlinic.objects.all()
doctor=Doctors.objects.all()
context={'setting':setting ,'doctor':doctor,'policlinic':policlinic}
if request.method=='POST':
form=AppointmentForm(request.POST)
if form.is_valid():
current_user=request.user
data=Randevu()
data.user_id=current_user.id
data.phone=form.cleaned_data['phone']
data.email=form.cleaned_data['email']
data.date=form.cleaned_data['date']
data.time=form.cleaned_data['time']
data.payment=form.cleaned_data['payment']
data.insurance=form.cleaned_data['insurance']
data.note=form.cleaned_data['note']
data.ip=request.META.get('REMOTE_ADDR')
data.save()
messages.success(request,"DONE! :)")
return render(request,'randevu.html',context)
messages.warning(request,"ERROR!")
return render(request,'randevu.html',context)
urls.py
urlpatterns = [
path('randevu',views.randevu,name='randevu') ]
randevu.html
<!-- MAKE AN APPOINTMENT -->
<section id="appointment" data-stellar-background-ratio="3">
<div class="container">
<div class="row">
<div class="col-md-6 col-sm-6">
<img src="{% static 'images/appointment-image.jpg' %}" class="img-responsive" alt="">
</div>
<div class="col-md-6 col-sm-6">
<!-- CONTACT FORM HERE -->
<form id="appointment-form" role="form" action="{% url 'randevu' %}" method="post">
<!-- SECTION TITLE -->
<div class="section-title wow fadeInUp" data-wow-delay="0.4s">
<h2>Randevu Alın</h2>
{%if messages%}
{%for message in messages%}
<div class="alert alert-{{message.tags}}"role="alert">
{{message}}
</div>
{%endfor%}
{%endif%}
</div>
{% csrf_token %}
<div class="wow fadeInUp" data-wow-delay="0.8s">
<div class="col-md-6 col-sm-6">
<label for="email">E-mail</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Your Email">
</div>
<div class="col-md-6 col-sm-6">
<label for="telephone">Telefon Numaranız</label>
<input type="tel" class="form-control" id="phone" name="phone" placeholder="Phone">
</div>
<div class="col-md-6 col-sm-6">
<label for="date">Tarih</label>
<input type="date" name="date" id="date" value="" class="form-control">
</div>
<div class="col-md-6 col-sm-6">
<label for="time">Zaman</label>
<input type="time" name="time" id="time" value="" class="form-control">
</div>
<div class="col-md-6 col-sm-6">
<label for="select">Poliklinik Seçiniz</label>
<select name="policlinic" class="form-control" id="policlinic">
{% for rs in policlinic %}
<option>{{rs.title}}</option>
{%endfor%}
</select>
</div>
<div class="col-md-6 col-sm-6">
<label for="select">Doktor Seçiniz</label>
<select name="doctor" class="form-control" id="doctor">
{% for rs in doctor %}
<option>{{rs.name}}</option>
{%endfor%}
</select>
</div>
<div class="col-md-6 col-sm-6">
<label for="select">Ödeme Yöntemi</label>
<select name="payment" class="form-control" id="payment">
<option>Nakit</option>
<option>Banka Kartı</option>
<option>Kredi Kartı</option>
<option>Diğer</option>
</select>
</div>
<div class="col-md-6 col-sm-6">
<label for="select">Sigorta</label>
<select name="insurance" class="form-control" id="insurance">
<option>SGK</option>
<option>AXA Sağlık Sigortası</option>
<option>Anadolu Sağlık Sigortası</option>
<option>Allianz Sağlık Sigortası</option>
<option>Akbank Sağlık Sigortası</option>
<option>Tamamlayıcı Türkiye Sağlık Sigortası</option>
<option>Diğer (Belirtiniz)</option>
</select>
</div>
<div class="col-md-12 col-sm-12">
<label for="Message">Belirtmek istediğiniz herhangi bir durum</label>
<textarea class="form-control" rows="5" id="note" name="note" placeholder="Notunuz"></textarea>
{%if user.id is not None%}
<button type="submit" class="form-control" id="cf-submit" name="submit">Submit Button</button>
{%else%}
Randevu oluşturmak için login olunuz!
{% endif %}
</div>
</div>
</form>
</div>
</div>
</div>
</section>
It's my appointment page:
enter image description here
Because get method is used to render the page
and in views.py you dont write
if request.method=='GET':
As a result, the error message is executed while there is no error
add this :
if request.method=='GET':

Django POST method is not receiving all input fields from HTML

please I would like to ask for help. I'm creating a web-based application and I'm having a hard time when I try to get the data from the HTML form and receive it through the POST method in Django.
It's pulling data only from one field and I really appreciate your help in figuring out why it's not pulling information from the other fields only from the location field. Thank you very much!
HTML = create-request.html
<form action="{% url 'save_request' %}" id="checklistForm" name="checklistForm" enctype="multipart/form-data" method="POST">
{% csrf_token %}
<section id="step-1" class="form-step">
<div class="mt-3">
{% include 'home/1_resource-request.html' %}
</div>
</section>
</form>
HTML = home/1_resource-request.html
{% block stylesheets %}{% endblock stylesheets %} {% block content %}
<div class="pcoded-content">
<div class="pcoded-inner-content">
<div class="main-body">
<div class="page-wrapper">
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<h5>Resource Request</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<form>
<div class="form-group">
<label for="checklistID">Checklist Number</label>
<input type="text" class="form-control" id="checklistID" name="checklistnum" placeholder="123456" disabled/>
</div>
<div class="form-group">
<label for="location_ID">CMPA Location</label>
<select class="form-control" id="location_ID" name="location">
<option selected>Select</option>
<option>Brazil</option>
<option>Canada</option>
<option>Mexico</option>
<option>SSA</option>
<option>United States</option>
</select>
</div>
</form>
</div>
<div class="col-md-6">
<form>
<div class="form-group">
<label for="support_id">CMPA Support Needed</label>
<select class="form-control" id="support_id" name="support">
<option selected>Select</option>
<option>Both</option>
<option>PMA - Financial Management</option>
<option>PMO - Project Administration</option>
</select>
</div>
<div class="form-group">
<label for="band_pma_id">Band (PMA)</label>
<select class="form-control" id="band_pma_id" name="band_pma">
<option selected>Select</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
</select>
<small id="textInfo1" class="form-text text-muted">There is no B4 for US and CA - in progress.</small>
</div>
<div class="form-group">
<label for="band_pmo_id">Band (PMO)</label>
<select class="form-control" id="band_pmo_id" name="band_pmo">
<option selected>Select</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
</select>
<small id="textInfo2" class="form-text text-muted"
>There is no B4 for US and CA - in progress.</small
>
</div>
<div class="mt-3">
<button class="button btn-navigate-form-step" type="button" step_number="2">Next</button>
<button class="button2 btn btn-outline-primary " type="submit">Save</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock content %}
Django/Python = views.py
def save_request(request):
#print(request.POST)
if request.method == 'POST':
context = {}
location = request.POST.get('location', None)
support = request.POST.get('support', None)
band_PMA = request.POST.get('bandPMA', None)
band_PMO = request.POST.get('bandPMO', None)
ippf = request.POST.get('ippf', None)
print(location, support, band_PMA, band_PMO, ippf)
return render(request, 'home/create-request.html', context=context)
That html defines many different forms. The first form has the location input element, the second form has the support input element, and so on.
Only one form can be submitted at a time. By default it is the first form on the page, so that's why you only see the location element.
I think you need to rewrite the html to have only one form.
That is because you have many tags.
You need to keep only one, the one wrapping your include, so do that :
<form action="{% url 'save_request' %}" id="checklistForm" name="checklistForm" enctype="multipart/form-data" method="POST">
{% csrf_token %}
<section id="step-1" class="form-step">
<div class="mt-3">
{% include 'home/1_resource-request.html' %}
</div>
</section>
</form>
and that :
HTML = home/1_resource-request.html
{% block stylesheets %}{% endblock stylesheets %} {% block content %}
<div class="pcoded-content">
<div class="pcoded-inner-content">
<div class="main-body">
<div class="page-wrapper">
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<h5>Resource Request</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="checklistID">Checklist Number</label>
<input type="text" class="form-control" id="checklistID" name="checklistnum" placeholder="123456" disabled/>
</div>
<div class="form-group">
<label for="location_ID">CMPA Location</label>
<select class="form-control" id="location_ID" name="location">
<option selected>Select</option>
<option>Brazil</option>
<option>Canada</option>
<option>Mexico</option>
<option>SSA</option>
<option>United States</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="support_id">CMPA Support Needed</label>
<select class="form-control" id="support_id" name="support">
<option selected>Select</option>
<option>Both</option>
<option>PMA - Financial Management</option>
<option>PMO - Project Administration</option>
</select>
</div>
<div class="form-group">
<label for="band_pma_id">Band (PMA)</label>
<select class="form-control" id="band_pma_id" name="band_pma">
<option selected>Select</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
</select>
<small id="textInfo1" class="form-text text-muted">There is no B4 for US and CA - in progress.</small>
</div>
<div class="form-group">
<label for="band_pmo_id">Band (PMO)</label>
<select class="form-control" id="band_pmo_id" name="band_pmo">
<option selected>Select</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
</select>
<small id="textInfo2" class="form-text text-muted"
>There is no B4 for US and CA - in progress.</small
>
</div>
<div class="mt-3">
<button class="button btn-navigate-form-step" type="button" step_number="2">Next</button>
<button class="button2 btn btn-outline-primary " type="submit">Save</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock content %}

Image not being uploaded .I want to upload the image and save it into the database i've given the media root and media url

applyonline.html(I have given file fields for adhaarcopy and idcopy)
<body ng-app="">
{% extends "pmmvyapp/base.html" %}
{% load crispy_forms_tags %}
{% load static %}
{% block content%}
<div class="col-md-8">
<form method="post" action="/personal_detail/">
{% csrf_token %}
<div class="form-group">
<div class=" mb-4">
<h6><u>(*Mandatory Fields)Please Fill up the details below </u></h6>
</div>
<legend class="border-bottom mb-4" ,align="center">1.Beneficiary Details</legend>
<label for="formGropuNameInput">Does Beneficiary have an Adhaar Card?*</label>
<input type="radio" name="showHideExample" ng-model="showHideTest" value="true">Yes
<input type="radio" name="showHideExample" ng-model="showHideTest" value="false">No
<!--logic for yes-->
<div ng-if="showHideTest=='true'">
<div class="form-group">
<label for="formGropuNameInput">Name of Beneficiary(as in Aadhar Card)*</label>
<input name="beneficiary_adhaar_name" class="form-control" id="formGroupNameInput" placeholder="Enter name of Beneficiary as in Aadhar Card" required>
</div>
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFile" name="adhaaarcopy">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>
</div>
<!--logic for no-->
<div ng-if="showHideTest=='false'">
<div class="form-group">
<div class="form-group">
<label for="adhaar_eid">Aadhaar Enrollment ID(EID):</label>
<input name="adhaar_eid" id="identityno" class="form-control" required>
</div>
<div class="form-group">
<label for="formGropuNameInput">Name of Beneficiary(as in Identity Card)* </label>
<input name="beneficiary_id_name" class="form-control" id="formGroupNameInput" placeholder="Enter your name" required>
</div>
<div class="form-group">
<label for="idno">Identity Number(Enclose Copy of Identity Card)*:</label>
<input name="idno" id="identityno" class="form-control" required>
</div>
<div class="custom-file">
<input type="file" class="custom-file-input" name="idcopy" id="customFile">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary" style="margin-bottom:10px ">Submit</button>
</form>
</div>
{% endblock %}
</body>
this is my views.py i've used POST.get
#login_required
def personal_detail(request):
# ShowHideExample = request.POST.get('showHideExample',False)
beneficiary_adhaar_name=request.POST.get('beneficiary_adhaar_name')
adhaarno=request.POST.get('adhaarno')
adhaarcopy=request.POST.get('adhaarcopy')
idcard=request.POST.get('idcard')
adhaar_eid=request.POST.get('adhaar_eid')
beneficiary_id_name=request.POST.get('beneficiary_id_name')
idno=request.POST.get('idno')
idcopy=request.POST.get('idcopy')
apply_online = Personal_Detail(beneficiary_adhaar_name=beneficiary_adhaar_name,adhaarno=adhaarno,adhaarcopy=adhaarcopy,
idcard=idcard,adhaar_eid=adhaar_eid,beneficiary_id_name=beneficiary_id_name,idno=idno,idcopy=idcopy)
apply_online.save()
return render(request,'users/applyonline.html')
this is my models.py where i have created FileField for both
class Personal_Detail(models.Model):
beneficiary_adhaar_name=models.TextField(blank=True, null=True)
adhaarno=models.IntegerField(blank=True, null=True)
adhaarcopy = models.FileField(upload_to='adhaar/')
idcard=models.TextField(blank=True, null=True)
adhaar_eid=models.IntegerField(blank=True,null=True)
beneficiary_id_name=models.TextField(blank=True, null=True)
idno=models.IntegerField(blank=True, null=True)
idcopy=models.FileField(upload_to='identitycard/')
def __str__(self):
return self.beneficiary_adhaar_name or self.beneficiary_id_name
settings.py I have given the media root and provided the media url
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR,'media')
MEDIA_URL ='/media/'
CRISPY_TEMPLATE_PACK='bootstrap4'
Like I want to know how can I upload the images like what should be my next steps.
You should get the file after submitted the form as below...
idcopy = request.FILES['idcopy']
adhaaarcopy = request.FILES['adhaaarcopy']
insted of...
idcopy=request.POST.get('idcopy')
adhaaarcopy=request.POST.get('adhaaarcopy')
And so on for other fields...
After that you can save and get it in appropriate location in media.

NOT NULL constraint failed: adminside_event.event_data

I have problem with my code which is i try to submit my Event form in the models. But when i run the form it will show the whole form (and another thing is that it will not show the values in the select box of the rounds) and when i click on the the submit button it will through an error.Please help me out this.
VIEW SIDE CODE:--
def addevents(request):
if request.method=="POST":
name=request.POST['events']
est=request.POST['starttime']
eet=request.POST['endtime']
s=Event()
s.ename=name
s.event_start_time=est
s.event_end_time=eet
s.save()
cats = request.POST.getlist('cats')
for i in cats:
s.categories.add(Category.objects.get(id=i))
s.save()
roundd = request.POST.getlist('rround')
for j in roundd:
s.rounds.add(Round.objects.get(id=j))
s.save()
return render(request,'adminside/addevents.html')
else:
rounds = Round.objects.all()
categories = Category.objects.all()
return render(request,'adminside/addevents.html',{'categories':categories,'rounds':rounds})
MODELS SIDE:-
class Event(models.Model):
ename=models.CharField(max_length=200)
categories = models.ManyToManyField(Category)
event_data = models.DateField()
event_start_time = models.TimeField()
event_end_time = models.TimeField()
rounds = models.ManyToManyField(Round)
EVENT PAGE FORM:-
{% extends 'adminside/master.html' %}
{% block content %}
<div class="col-12">
<div class="card">
<div class="card-body">
<h4 class="card-title">Events</h4>
<p class="card-description"> All fields are Compulsory </p>
<form class="forms-sample" method="POST">
{% csrf_token %}
<div class="form-group">
<label for="exampleInputEmail1">Add Event</label>
<input type="text" class="form-control" name="events" id="exampleInputEmail1" placeholder="Enter Event">
</div>
<div class="form-group">
<label>Categories:</label>
<select class="form-control" multiple name="cats">
{% for i in categories %}
<option value="{{ i.id }}">{{ i.cname }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="exampleInputEmail1">Event Start Time</label>
<input type="text" class="form-control" name="starttime" id="exampleInputEmail1" placeholder="Enter Event Start Time">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Event End Time</label>
<input type="text" class="form-control" name="endtime" id="exampleInputEmail1" placeholder="Enter Event End Time">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Round Name</label>
<select class="form-control form-control-lg" id="exampleFormControlSelect1" multiple name="rround">
{% for i in rounds %}
<option value="{{i.id}}">{{i.round}}</option>
{% endfor %}
</select>
</div>
<button type="submit" value=Addme class="btn btn-success mr-2">Submit</button>
<button class="btn btn-light">Cancel</button>
</form>
</div>
</div>
</div>
{% endblock %}
in addevents view you need to add something in event_data before saving because this value do not accept null or modify your models.py
event_data = models.DateField()
modify this to default value like the current time
event_data = models.DateField(default=timezone.now)
hope this helps

POST no save to model. return "this field is required" error on Django

Hi friends I am new for Django
I want to make a form with bootstrap.
When I click submit Button Post Data is
<QueryDict: {'csrfmiddlewaretoken': ['mjzoKZ1GPuHMCR6LQwNpUxDW0Y1KyxRgySSynPSOU7eHK8Zlm5dgqvWwhXpD3F0M'], '<input type="text" name="borclu" maxlength="36" required id="id_borclu">': ['asfasf'], '<input type="email" name="borclu_mail" maxlength="25" required id="id_borclu_mail">': ['asdasd'], '<textarea name="borcluAdres" cols="40" rows="10" maxlength="80" required id="id_borcluAdres">\r\n</textarea>': ['asdasd'], '<input type="text" name="borcluTelefon" maxlength="11" required id="id_borcluTelefon">': ['asdasd'], '<input type="number" name="tutar" required id="id_tutar">': ['asdasd'], '<input type="text" name="cek_tarih" required id="id_cek_tarih">': ['12-02-2019']}>
But data no saved to model
My model like that;
class cekler(models.Model):
borclu=models.CharField(max_length=36,verbose_name="Keşideci")
borcluAdres=models.TextField(max_length=80,verbose_name="Keşideci Adresi")
borclu_mail = models.EmailField(max_length=25,verbose_name="Keşideci E Posta Adresi")
borcluTelefon=models.CharField(max_length=11,verbose_name="Keşideci Telefon")
tutar=models.IntegerField(verbose_name="Tutar")
bankalar = (
('Ziraat Bankası', 'Ziraat Bankası'),
('YapıKredi Bankası', 'YapıKredi Bankası'),
('Vakıflar Bankası', 'Vakıflar Bankası'),
('Teb', 'TEB'),
)
banka=models.CharField(max_length=20, choices=bankalar, verbose_name="Banka Adı:")
cek_tarih=models.DateField(verbose_name="Çek Tarihi")
son_tarih = models.DateTimeField(blank=True, null=True)
def _get_gecen_gun(self):
"Returns the person's full name."
day=date.today()-self.cek_tarih
ggun = str(day)
ggun = ggun.split(' ')[0]
return '%s' % (ggun)
gecenGun = property(_get_gecen_gun)
def __str__(self):
return self.borclu
def save(self, *args, **kwargs):
if not self.pk:
self.son_tarih = self.cek_tarih + datetime.timedelta(days=80)
super(cekler, self).save(*args, **kwargs)
class Meta:
ordering = ['-id']
My Form.py;
from django import forms
from .models import cekler
class CekForm(forms.ModelForm):
class Meta:
model=cekler
fields=[
'borclu',
'borcluAdres',
'borclu_mail',
'borcluTelefon',
'tutar',
'banka',
'cek_tarih',
]
My Template
<form method="post">
{% csrf_token %}
<div class="container">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputEmail4">Keşideci Adı</label>
<input type="text" name='{{ form.borclu }}' class="form-control" >
</div>
<div class="form-group col-md-6">
<label for="inputPassword4">Borçlu Mail</label>
<input type="text" name='{{ form.borclu_mail }}' class="form-control" >
</div>
</div>
<div class="form-group">
<label for="inputAddress">Borçlu Adres</label>
<input type="text" name='{{ form.borcluAdres }}' class="form-control" >
</div>
<div class="form-group">
<label for="inputAddress2">Borçlu Telefon</label>
<input type="text" name='{{ form.borcluTelefon }}' class="form-control" >
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputCity">Tutar</label>
<input type="text" name='{{ form.tutar }}' class="form-control" >
</div>
<div class="form-group col-md-4">
<label for="inputState">Banka</label>
<select id="inputState" class="form-control">
{% for value in form.banka %}
<option >{{ value }}</option>
{% endfor %}
</select>
</div>
<div class="form-group col-md-2">
<label for="inputZip">Çek Tarihi</label>
<input type="text" name='{{ form.cek_tarih }}' class="form-control" >
</div>
</div>
<input type="submit" class="btn btn-primary" value="Ekle">
</div>
</form>
I think problem from my Bootstrap implementation. Before this implemantation I use form with 'form.as_p' and it was correct.
Now when I click button anything happen. No error. But data no save on my model.
You're putting the wrong thing in your template. You should be able to see from the submitted data that each field has some HTML as its key, which is obviously wrong.
Instead of name='{{ form.borclu }}' etc you should probably do name='{{ form.borclu.name }}'.

Categories