Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#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 casseen, 16 years ago

Version: 1.0SVN

comment:2 by casseen, 16 years ago

Component: UncategorizedForms

comment:3 by casseen, 16 years ago

Last line of description should say:

[...] But I guess *it* should work in both ways. [...]

comment:4 by Karen Tracey, 16 years ago

Resolution: invalid
Status: newclosed

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 casseen, 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.

Note: See TracTickets for help on using tickets.
Back to Top