Opened 5 years ago

Closed 5 years ago

#22925 closed New feature (wontfix)

Provide ability to make ModelForm fields required by specifying them explicitly in Meta

Reported by: Andriy Sokolovskiy Owned by: Andriy Sokolovskiy
Component: Forms Version: master
Severity: Normal Keywords: modelform, form, required field
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I'm tired to always specify, which fields are must be required in that usual way:

        self.fields['tag_line'].required = True
        self.fields['cover'].required = True
        self.fields['logo'].required = True

So I propose to add extra_required property to ModelForm Meta class.
A way to make fields required:

    class Meta:
        model = models.SomeModel
        extra_required = ['tag_line', 'cover', 'logo']

Patch are in the attachments.

Attachments (1)

extra_required.patch (3.5 KB) - added by Andriy Sokolovskiy 5 years ago.
implements extra_required

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by Andriy Sokolovskiy

Attachment: extra_required.patch added

implements extra_required

comment:1 Changed 5 years ago by Andriy Sokolovskiy

I also created a pull request for this.

comment:2 Changed 5 years ago by Tim Graham

Resolution: wontfix
Status: newclosed

While I somewhat like the idea, I'm going to won't fix this for reasons described in #17924 and Please open a thread on the DevelopersMailingList if you want to argue otherwise.

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