Opened 16 years ago
Closed 13 years ago
#9588 closed New feature (fixed)
provide **kwargs argument to GenericInlineModelAdmin.get_formset
Reported by: | Owned by: | Brian Rosner | |
---|---|---|---|
Component: | contrib.contenttypes | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | 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
InlineModelAdmin.get_formset provides kwargs to override defaults:
def get_formset(self, request, obj=None, **kwargs): """Returns a BaseInlineFormSet class for use in admin add/change views.""" if self.declared_fieldsets: fields = flatten_fieldsets(self.declared_fieldsets) else: fields = None if self.exclude is None: exclude = [] else: exclude = self.exclude defaults = { "form": self.form, "formset": self.formset, "fk_name": self.fk_name, "fields": fields, "exclude": exclude + kwargs.get("exclude", []), "formfield_callback": self.formfield_for_dbfield, "extra": self.extra, "max_num": self.max_num, } defaults.update(kwargs) return inlineformset_factory(self.parent_model, self.model, **defaults)
Shouldn't we do the same for GenericInlineModelAdmin.get_formset ?
Potential Patch:
def get_formset(self, request, obj=None, **kwargs): if self.declared_fieldsets: fields = flatten_fieldsets(self.declared_fieldsets) else: fields = None defaults = { "ct_field": self.ct_field, "fk_field": self.ct_fk_field, "form": self.form, "formfield_callback": self.formfield_for_dbfield, "formset": self.formset, "extra": self.extra, "can_delete": True, "can_order": False, "fields": fields, } defaults.update(kwargs) return generic_inlineformset_factory(self.model, **defaults)
I chose the "Contrib Apps" component because there is no "contrib.contenttypes".
Attachments (2)
Change History (13)
comment:1 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
If you're having a go at fixing this one, you should consider fixing #9122 at the same time, it's kinda related in the "Make the GenericInlineModelAdmin more like the InlineModelAdmin" category. :)
comment:3 by , 15 years ago
milestone: | → 1.2 |
---|---|
Version: | 1.0 → SVN |
comment:4 by , 15 years ago
milestone: | 1.2 |
---|
1.2 is feature-frozen, moving this feature request off the milestone.
comment:5 by , 14 years ago
Component: | Contrib apps → contrib.contenttypes |
---|
comment:6 by , 14 years ago
Needs tests: | set |
---|---|
Severity: | → Normal |
Type: | → New feature |
by , 13 years ago
comment:7 by , 13 years ago
Easy pickings: | unset |
---|---|
Needs tests: | unset |
comment:8 by , 13 years ago
Needs tests: | set |
---|
Thanks a lot for the patch. It is a simple change but tests are still needed. Passing a couple of kwargs and making sure that they override the defaults would be enough.
comment:9 by , 13 years ago
Needs tests: | unset |
---|
I was just thinking about this today as I was going through this code.