#10949 closed (invalid)
In forms.ModelForm Meta.fields needs to be a list if only single field is defined
Reported by: | casseen | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The following is not working! It returns a broken form if instantiated:
class ExampleForm(forms.ModelForm): class Meta: model = ExampleModel fields = ('single_field')
It is working if Meta.fields is set to a list:
class ExampleForm(forms.ModelForm): class Meta: model = ExampleModel fields = ['single_field']
If this is intended behaviour it should be documented! But I guess I should work in both ways. This behaviour is introduced with r10062.
Change History (5)
comment:1 by , 16 years ago
Version: | 1.0 → SVN |
---|
comment:2 by , 16 years ago
Component: | Uncategorized → Forms |
---|
comment:3 by , 16 years ago
comment:4 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
It looks to me like your sequence version is broken by virtue of the fact that you have left off the trailing comma for your single-element tuple. If that is not the cause of the problem, you may reopen but please include some details of what 'broken form' means.
comment:5 by , 16 years ago
Ok, a final comma clears this case! I am sorry. Still learning python as you see ; ) I was confused because it worked without a final comma before r10062.
Last line of description should say:
[...] But I guess *it* should work in both ways. [...]