#10208 closed (fixed)
ModelAdmin ignores 'exclude' and 'fields' attributes of ModelForm.Meta
Reported by: | Owned by: | Alex Gaynor | |
---|---|---|---|
Component: | Forms | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Keith Bussell, django@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This way exclusion works:
class RegionAdmin(admin.ModelAdmin): #form = RegionForm exclude = ('changed_by', 'last_changed') admin.site.register(Region, RegionAdmin)
but this way:
class RegionAdmin(admin.ModelAdmin): form = RegionForm #exclude = ('changed_by', 'last_changed') admin.site.register(Region, RegionAdmin)
where
class RegionForm(forms.ModelForm): class Meta: model = Region exclude = ('changed_by', 'last_changed')
does not. This ticket is probably related to the #8071, however there are no foreing keys in the model.
Attachments (4)
Change History (15)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 16 years ago
Has patch: | set |
---|
My fix checks the form's exclusion list if the admin's exclusion list isn't specified. Added a test to use the form described in the ticket description.
comment:5 by , 16 years ago
Cc: | added |
---|
by , 16 years ago
Attachment: | custom-modeladmin-form.diff added |
---|
comment:6 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
by , 16 years ago
Attachment: | custom-modeladmin-form.3.diff added |
---|
Fixed it for InlineModelAdmin as well.
comment:7 by , 16 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:8 by , 16 years ago
Cc: | added |
---|
comment:9 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:10 by , 16 years ago
Note:
See TracTickets
for help on using tickets.
just as a workaround until this gets fixed, you can do something like
Unnecessary, but avoids repeating myself