On Jun 25, 1:24 pm, steveneo <steve...@gmail.com> wrote: > I try to use Django in a new project. Honestly, it is very bad > experience. It looks not boosting my development speed. Today, I > almost give up and begin to look up another Python framework.... > > One question, does anyone use a hiddenInput in Form? Something like: > class ProfileForm(forms.Form): > cpwd = forms.BooleanField(widget=forms.HiddenInput, initial=False) > > Whatever I use {{form.as_p}} or customized form. It always reports > "(Hidden field cpwd) This field is required." I check out the HTML > source, the hidden field is just there: > <input type="hidden" name="cpwd" value="False" id="id_cpwd" /> > > I try to use CharField() instead, it looks all right but I don't want > to do such hack... > > I really feel a little crazy to trace the reason.... It looks a very > simple usage but so buggy... I am a little suspect whether there are > more bugs ahead of my development process.
So, coming entirely new to a framework, you have a single problem, and this makes it a 'very bad experience'? Maybe you should get a sense of proportion. In the meantime, the documentation on BooleanField is quite clear: "Validates that the check box is checked (i.e. the value is True) if the field has required=True." And the box underneath explains further: "Since all Field subclasses have required=True by default, the validation condition here is important. If you want to include a checkbox in your form that can be either checked or unchecked, you must remember to pass in required=False when creating the BooleanField." So, since you want the value to be False, you need to pass in required=False in your declaration. -- DR. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---