Hacker News new | past | comments | ask | show | jobs | submit login
Core Concepts of Django Forms (pydanny.com)
38 points by pydanny on March 29, 2013 | hide | past | favorite | 7 comments



I might have been using an old version of Django, or I did it wrong, but hidden fields seemed to be a major pain with Django forms. Just because a field isn't marked a editable, doesn't mean that it should be included in the form data. It would be nice is editable=False, meant that "You can't edit this field and hidden=True meant: You will not see this field, editable=False would be assumes in this case.

We tried to do a few forms with Django forms, only to find that the designer wanted something that made it easy to just skip the Django forms all together and just do them form by hand.


Hidden fields aren't a problem in Django. Can you provide a code sample demonstrating your issues?


you are looking for Meta: exclude = ('field1', 'field2', )

displaying a field as hidden doesn't make it uneditable.


Actually, the standard Django documentation on forms is an excellent guide: https://docs.djangoproject.com/en/1.5/topics/forms/


In forms validate dictionaries, the example makes no sense. At first, I assumed this was a duplicate key issue, but I cannot reproduce this problem.

>>> good_form = MyForm({"title": "Two Scoops of Django"}) >>> good_form.is_valid() True >>> good_form.errors {} >>> bad_form = MyForm({"title": "Two Scoops of Django"}) >>> bad_form.is_valid() True >>> bad_form.errors {}


D'oh! Typo on my part. Fixed.


I wish I read this earlier today. Good article.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: