Re: form issue.
So is blank = True and null = True in the model?
What I have done is working fine in another form, so why is it not working here? <confused>Cheers, Nigel
07914 740972
07914 740972
On 13 September 2013 11:59, Daniel Roseman <daniel@roseman.org.uk> wrote:
On Friday, 13 September 2013 08:45:51 UTC+1, Nigel Legg wrote:I have a form with a lot of fields in it. Users will never require data in all fields, so most have the required = False tag:<snip>
[This is a good example of how the for would be used]
When I submit the form, I get the error "vChoice1_score cannot be null."I thought that required = False would allow that?Am I doing something wrong here?Well, you're doing quite a lot of things wrong here. In particular, you're using a plain Form instead of a ModelForm, which means you have to define and all the fields manually and then copy them over to the model object, when you could just call form.save() to do it automatically with a ModelForm.But the main issue is that you have not declared any of your model fields as null=True, so the database will be expecting value. Again, declare all the fields as blank=True and the integerfields as null=True as well, then define a simple modelform without overriding any of the fields, and your app will work with about a third of the code.--DR.--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home