It seems in this particular case you don't need the boolean field in the model. As the behaviour you want has to do only with the form, you just have to add an additional required checkbox in this model form.
class MyModelForm(forms.ModelForm):
involved = forms.BooleanField(required=True)
class Meta:
model = MyModel
cheers
On Wednesday, 1 August 2012 13:37:12 UTC+2, Jon Underwood wrote:
Hi,My checkboxes are giving me grief.I want to make it required for the user to check a checkbox before being allowed to submit a forms.I'm using model forms so the checkbox is defined as a models.BooleanField in my models.py. I have included blank=False, though this should be the default.In the admin the checkboxes aren't required to be checked. When displaying the form in a template I can set required="True" as follows: <input type="checkbox" required="True" check_test="True" name="involved" id="id_involved"/>This works in most browsers, though not Safari for some reason.Is there a better method? I've messed around with this for ages!Thank you in advance.Jon
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/K2iX2zo_vUMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment