Opened 15 years ago
Last modified 3 years ago
#12238 new
ModelAdmin ignores dynamic fields of ModelForm — at Version 3
Description (last modified by ) ¶
If a ModelForm is created and then modified to programatically add fields (say, in __init__
), ModelAdmin ignores these fields when rendering the form. If one of these fields is added to the ModelForm's Meta
, the field shows up just fine.
I would expect the field to display without the coaxing in Meta.fields
.
- Create a ModelForm
- Add it to ModelAdmin
- View Form
- Update ModelForm's
__init__
to includeself.fields['xyz'] = forms.CharField(max_length=255, initial='keke')
- View Form (note no change)
- Update ModelForm's
Meta.fields
to include "xyz" - View Form (note the change)
According to the ticket's flags, the next step(s) to move this issue forward are:
- To add tests to the patch, then uncheck the "Needs tests" flag on the ticket.
If creating a new pull request, include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (3)
comment:1 by , 15 years ago
Component: | Uncategorized → django.contrib.admin |
---|
comment:2 by , 15 years ago
Has patch: | set |
---|
comment:3 by , 15 years ago
Description: | modified (diff) |
---|---|
Has patch: | unset |
(reformat description, also it hasn't a patch until it has a patch)
I've solved this in the meantime by updating contrib/admin/options.py in:
Seems to be a harmless fix, possible to get this applied upstream?