Opened 15 years ago

Last modified 3 years ago

#12238 new

ModelAdmin ignores dynamic fields of ModelForm — at Initial Version

Reported by: anonymous Owned by: nobody
Component: contrib.admin Version: 1.1
Severity: Normal Keywords: modelform modeladmin dynamic field
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

  1. Create a ModelForm
  2. Add it to ModelAdmin
  3. View Form
  4. Update ModelForm's init to include "self.fieldsxyz = forms.CharField(max_length=255, initial='keke')"
  5. View Form (note no change)
  6. Update ModelForm's Meta.fields to include "xyz"
  7. View Form (note the change)

Change History (0)

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