Hello,
Can we have the template?
Did you rendered the hidden fields id of your forms ?
Dump (by printing) the request.POST informations to see
if you received any "id" :)
On 02/19/2015 04:25 PM, Werner Brand wrote:
I cannot seem to figure this, although I suspects it is really
elementary:
I have two models:
class Employee(models.Model):
id_number = models.CharField(max_length=13)
surname = models.CharField(max_length=100)
name = models.CharField(max_length=100)
class Payslip(models.Model):
surname = models.CharField(max_length=100)
name = models.CharField(max_length=100)
salary = models.DecimalField(max_digits=20, decimal_places=2)
In my forms:
class PayslipForm(ModelForm):
class Meta:
model = Payslip
fields = ['surname', 'name', 'salary']
PayslipFormSet = modelformset_factory(Payslip, extra=0)
In views.py:
def Payslip(request):
employee = Employee.objects.all()
formset = PayslipFormSet(queryset=employee)
context = {'formset': formset}
return render(request, 'file.html', context)
def PayslipSubmit(request):
f = PayslipFormSet(request.POST)
if f.is_valid():
f.save()
return HttpResponse('Submitted')
else:
return HttpResponse(f.errors)
The problem is that when I submit I get the following each form in
formset:
* id
o Select a valid choice. That choice is not one of the available
choices.
I hope someone can help!
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/8c766350-f426-475c-aac5-15f42952ce00%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/8c766350-f426-475c-aac5-15f42952ce00%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/54E61AC4.8040504%40arkade.info.
For more options, visit https://groups.google.com/d/optout.