[Django] #35872: Add error message when invalid ModelForm Meta attributes are set

10 views
Skip to first unread message

Django

unread,
Oct 28, 2024, 9:21:32 PM10/28/24
to django-...@googlegroups.com
#35872: Add error message when invalid ModelForm Meta attributes are set
---------------------------------------+----------------------------
Reporter: jernwerber | Owner: jernwerber
Type: New feature | Status: assigned
Component: Forms | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
---------------------------------------+----------------------------
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,
[https://github.com/django/django/blob/e8e503551100af5c29d253870233dee838dbafa3/django/db/models/options.py#L218
a TypeError is raised]).
--
Ticket URL: <https://code.djangoproject.com/ticket/35872>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 29, 2024, 3:04:30 AM10/29/24
to django-...@googlegroups.com
#35872: Add error message when invalid ModelForm Meta attributes are set
-----------------------------+--------------------------------------
Reporter: jernwerber | Owner: jernwerber
Type: New feature | Status: closed
Component: Forms | Version: 5.0
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by Sarah Boyce):

* resolution: => wontfix
* status: assigned => closed

Comment:

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
[https://forum.djangoproject.com/c/internals/5 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
--
Ticket URL: <https://code.djangoproject.com/ticket/35872#comment:1>

Django

unread,
Oct 29, 2024, 3:45:14 AM10/29/24
to django-...@googlegroups.com
#35872: Add error message when invalid ModelForm Meta attributes are set
-----------------------------+--------------------------------------
Reporter: jernwerber | Owner: jernwerber
Type: New feature | Status: closed
Component: Forms | Version: 5.0
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------+--------------------------------------
Comment (by Carlton Gibson):

Worth noting that #5793 is a long-standing ticket to **allow** custom
Model Meta attributes… — it’s not monotonic here.
--
Ticket URL: <https://code.djangoproject.com/ticket/35872#comment:2>

Django

unread,
Oct 29, 2024, 8:41:26 PM10/29/24
to django-...@googlegroups.com
#35872: Add error message when invalid ModelForm Meta attributes are set
-----------------------------+--------------------------------------
Reporter: jernwerber | Owner: jernwerber
Type: New feature | Status: closed
Component: Forms | Version: 5.0
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------+--------------------------------------
Comment (by jernwerber):

Replying to [comment:2 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.
--
Ticket URL: <https://code.djangoproject.com/ticket/35872#comment:3>

Django

unread,
Oct 29, 2024, 8:51:34 PM10/29/24
to django-...@googlegroups.com
#35872: Add error message when invalid ModelForm Meta attributes are set
-----------------------------+--------------------------------------
Reporter: jernwerber | Owner: jernwerber
Type: New feature | Status: closed
Component: Forms | Version: 5.0
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------+--------------------------------------
Comment (by jernwerber):

Replying to [comment:1 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
[https://forum.djangoproject.com/c/internals/5 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!
--
Ticket URL: <https://code.djangoproject.com/ticket/35872#comment:4>
Reply all
Reply to author
Forward
0 new messages