Re: [Django] #12238: ModelAdmin ignores dynamic fields of ModelForm

9 views
Skip to first unread message

Django

unread,
Apr 14, 2022, 11:41:36 AM4/14/22
to django-...@googlegroups.com
#12238: ModelAdmin ignores dynamic fields of ModelForm
-------------------------------------+-------------------------------------
Reporter: anonymous | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.1
Severity: Normal | Resolution:
Keywords: modelform | Triage Stage: Accepted
modeladmin dynamic field |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by François Freitag):

> 6. Update !ModelForm's `Meta.fields` to include "xyz"

This step leaves the `Meta.fields` modified, because the `Meta` is only
instantiated when the `ModelForm` class is constructed. Thus, on the next
request, "xyz" will still be part of the `Meta.fields`. In my use case,
the field was added conditionally, and was unexpectedly present in the
`Meta.fields` on the next request.

This might be a pitfall for others.

--
Ticket URL: <https://code.djangoproject.com/ticket/12238#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages