Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 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:

Description

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.

Attachments (0)

Change History (2)

comment:1 Changed 5 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 5 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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.