#11905: modelform_factory returns a broken form when given wrong value for
fields
---------------------------------+------------------------------------------
Reporter: ben | Owner: nobody
Status: new | Milestone:
Component: Forms | Version: 1.1
Resolution: | Keywords: modelform_factory,
modelform, fields
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------+------------------------------------------
Changes (by ben):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Sorry screwed up the formatting, try:
{{{
>>> from django.forms.models import modelform_factory, form_for_fields
>>> from django.contrib.auth.models import User
>>> Form = modelform_factory(User, fields=['id', 'username'])
>>> Form.base_fields
{'id': None, 'username': <django.forms.fields.CharField object at
0xd4e4ad0>}
>>> print Form()
Traceback (most recent call last):
....
if self.field.label is None:
AttributeError: 'NoneType' object has no attribute 'label'
>>> Form = modelform_factory(User, fields=['no-field', 'username'])
>>> Form.base_fields
{'no-field': None, 'username': <django.forms.fields.CharField object at
0xd4eec10>}
>>> print Form()
Traceback (most recent call last):
....
AttributeError: 'NoneType' object has no attribute 'label'
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/11905#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---