Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#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)

list_editable_and_parent_link.diff (2.3 KB ) - added by Will Hardy 16 years ago.
Regression test showing this bug in action
list-editable.diff (6.5 KB ) - added by Alex Gaynor 16 years ago.

Download all attachments as: .zip

Change History (9)

by Will Hardy, 16 years ago

Regression test showing this bug in action

comment:1 by Will Hardy, 16 years ago

A couple of extra bits of potentially useful information:

  1. exception appears whether or not parent_link is set as a primary_key.
  1. 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 Alex Gaynor, 16 years ago

Owner: changed from nobody to Alex Gaynor
Triage Stage: UnreviewedAccepted

Assigning to me.

by Alex Gaynor, 16 years ago

Attachment: list-editable.diff added

comment:3 by Alex Gaynor, 16 years ago

Has patch: set

comment:4 by Will Hardy, 16 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 Jacob, 16 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Jacob, 16 years ago

Resolution: fixed
Status: newclosed

(In [10590]) Fixed #10799: fixed the use of list_editable with model inheritance and custom one-to-one parent links. Thanks, Alex Gaynor.

comment:7 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

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