Code

Opened 8 years ago

Closed 7 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
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: UI/UX:

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

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by oggie rob

Patch for _get_deleted_objects method

comment:1 Changed 8 years ago by anonymous

  • Version set to SVN

comment:2 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:3 Changed 7 years ago by earnestsloan@…

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:4 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from reopened to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.