Opened 10 years ago

Closed 10 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: dev
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

Description

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 10 years ago.
implements extra_required

Download all attachments as: .zip

Change History (3)

by Andriy Sokolovskiy, 10 years ago

Attachment: extra_required.patch added

implements extra_required

comment:1 by Andriy Sokolovskiy, 10 years ago

I also created a pull request for this.
See https://github.com/django/django/pull/2862

comment:2 by Tim Graham, 10 years ago

Resolution: wontfix
Status: newclosed

While I somewhat like the idea, I'm going to won't fix this for reasons described in #17924 and https://code.djangoproject.com/ticket/20000#comment:9. Please open a thread on the DevelopersMailingList if you want to argue otherwise.

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