Opened 18 years ago

Closed 17 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: dev
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

Description

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 18 years ago.
Patch for _get_deleted_objects method

Download all attachments as: .zip

Change History (5)

by oggie rob, 18 years ago

Attachment: atterror.diff added

Patch for _get_deleted_objects method

comment:1 by anonymous, 18 years ago

Version: SVN

comment:2 by Adrian Holovaty, 18 years ago

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 by earnestsloan@…, 17 years ago

Resolution: fixed
Status: closedreopened

comment:4 by Malcolm Tredinnick, 17 years ago

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