#10799 closed (fixed)
List editable breaks with model inheritance and parent_link=True
| Reported by: | Will Hardy | Owned by: | Alex Gaynor |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Keywords: | list_editable parent_link inheritance | |
| 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
Similar symptoms to #10622, the admin site raises an exception where the model explicity defines a parent_link and list_editable is set in the model's admin.
I have attached a regression test that shows this in action.
Attachments (2)
Change History (9)
by , 17 years ago
| Attachment: | list_editable_and_parent_link.diff added |
|---|
comment:1 by , 17 years ago
A couple of extra bits of potentially useful information:
- exception appears whether or not
parent_linkis set as aprimary_key.
- looking at line 950 of
django/contrib/admin/options.py:elif self.list_editable: FormSet = self.get_changelist_formset(request) formset = cl.formset = FormSet(queryset=cl.result_list)
The FormSet here looks ok (parent_link and non-parent_link version appear to be the same), but each of the forms in formset.forms is missing the field for the primary key. The result_list is of course the same with or without parent_link.
I find this strange because it appears to use the (no doubt well-tested) generic factory functions from forms.models.
I don't know the internal django code well enough to give a useful opinion here, but this is what I was able to observe.
comment:2 by , 17 years ago
| Owner: | changed from to |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
Assigning to me.
by , 17 years ago
| Attachment: | list-editable.diff added |
|---|
comment:3 by , 17 years ago
| Has patch: | set |
|---|
comment:4 by , 17 years ago
I probably should have given my regression test a more descriptive title and a docstring, eg:
def test_inheritance_parent_link(self):
" Ensure that the admin list_editable view works for models with parent_link. "
comment:5 by , 17 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:6 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Regression test showing this bug in action