Live data from Hacker News

Core Concepts of Django Forms

pydanny.com

1–8 of 8 posts

Re: Core Concepts of Django Forms

#2
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 {}

Re: Core Concepts of Django Forms

#3
post #2

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.

Re: Core Concepts of Django Forms

#6
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.

Re: Core Concepts of Django Forms

#7
post #6

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…

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

Re: Core Concepts of Django Forms

#8
post #6

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…

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

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