Opened 13 years ago

Closed 12 years ago

#1196 closed defect (fixed)

[patch] AttributeError when deleting related object in admin, if related object has custom primary key

Reported by: oggie rob (oz.robharvey@… Owned by: Adrian Holovaty
Component: contrib.admin Version: master
Severity: major Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I have a model like so:
class MyData(meta.Model):


class MyOtherData(meta.Model):

my_primary = meta.ForeignKey(MyData, primary_key=True, raw_id_admin=True)

When I use the delete button in admin to remove a MyData object, I get the following error:
AttributeError: 'MyOtherData' object has no attribute 'id'

The _get_deleted_objects() method is looking for the id field rather than using the model's pk.

Attachments (1)

atterror.diff (1.8 KB) - added by oggie rob 13 years ago.
Patch for _get_deleted_objects method

Download all attachments as: .zip

Change History (5)

Changed 13 years ago by oggie rob

Attachment: atterror.diff added

Patch for _get_deleted_objects method

comment:1 Changed 13 years ago by anonymous

Version: SVN

comment:2 Changed 13 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [1973]) Fixed #1196 -- Admin deletion step no longer assumes related objects have primary key named 'id'. Thanks, oggie rob

comment:3 Changed 12 years ago by earnestsloan@…

Resolution: fixed
Status: closedreopened

comment:4 Changed 12 years ago by Malcolm Tredinnick

Resolution: fixed
Status: reopenedclosed

If you're going to reopen a ticket, please provide details about what is going wrong. We need to know the Django version you are using (subversion changeset number if you are using a subversion checkout) and an example (as small as possible) of what is failing.

Reclosing until the extra information is provided, because in the current state, we can do nothing about this.

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