Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#11140 closed (invalid)

modelForm fields Meta, if only one specified results empty form

Reported by: davidarakelian Owned by: nobody
Component: Forms Version: master
Severity: Keywords: forms, modelForm, fields, meta, empty form
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I have the following Modelform.

class EditPicture(forms.ModelForm):
    class Meta:
        model = Photo
        fields = ('title','description')

If I change fields to ('title')

class EditPicture(forms.ModelForm):
    class Meta:
        model = Photo
        fields = ('title')

This produces an empty form. Whenever I try to built a form(from a model) with only 1 field it shows up an empty form.

Change History (2)

comment:1 Changed 7 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

That's because you specified a string, not an iterable (such as a tuple) for fields. Please don't use trac to ask support questions.

comment:2 Changed 7 years ago by davidarakelian

oh sorry,

so I am forced to use a

fields = ('title',)
instead of
fields = ('title')

If I want to have only one field based form... argh

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