Opened 3 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#35872 closed New feature (wontfix)

Add error message when invalid ModelForm Meta attributes are set

Reported by: jernwerber Owned by: jernwerber
Component: Forms Version: 5.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Invalid (e.g., non-existent, misspelled) attributes that are added to a ModelForm's inner Meta class are silently ignored, but they should instead raise an error since they would signal either a mistake or misunderstanding/misapplication of the Meta class (as is the case elsewhere, e.g., if an invalid attribute is included in a Model's inner Meta class, a TypeError is raised).

Change History (4)

comment:1 by Sarah Boyce, 3 weeks ago

Resolution: wontfix
Status: assignedclosed

Thank you for the ticket
I think I agree with this in principle. However, as this sounds backwards incompatible, can you first raise this on the Django forum and see what other folks think?
If we have community agreement that we should do this, you can link the discussion and reopen the ticket

comment:2 by Carlton Gibson, 3 weeks ago

Worth noting that #5793 is a long-standing ticket to allow custom Model Meta attributes… — it’s not monotonic here.

in reply to:  2 comment:3 by jernwerber, 3 weeks ago

Replying to Carlton Gibson:

Worth noting that #5793 is a long-standing ticket to allow custom Model Meta attributes… — it’s not monotonic here.

Oh wow, long-standing indeed (opened 17 years ago)! And it even references ModelForm's Meta class, somewhat more recently at 8 years ago. My (admittedly limited) understanding of Django's architecture was consistent with the first comment on that ticket, namely that these Meta classes are go-betweens for private parts of the API since the Meta class itself is essentially ignored once the corresponding attributes have been set on the ModelForm. The discussion on Model's Meta attributes still seems to support validation of the attributes, so even if custom attributes were to be allowed, I think one would still expect an error of some sort to be raised should an invalid attribute (however that's determined) be set.

in reply to:  1 comment:4 by jernwerber, 3 weeks ago

Replying to Sarah Boyce:

Thank you for the ticket
I think I agree with this in principle. However, as this sounds backwards incompatible, can you first raise this on the Django forum and see what other folks think?
If we have community agreement that we should do this, you can link the discussion and reopen the ticket

OK, I'll head over there and bring it up!

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