Code

Opened 9 years ago

Closed 9 years ago

#525 closed defect (fixed)

list_filter doesn't work with models which primary key is not named 'id'

Reported by: nesh <nesh [at] studioquattro [dot] co [dot] yu> Owned by: adrian
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I'm using package model and when I'm set list_filter to 'package' I'm getting following traceback.
It seems to that filter code doesn't work with models which primary key is not named 'id'.

There's been an error: Traceback (most recent call last): 
File "/Users/nesh/devel/django/django/core/handlers/base.py", line 64, in get_response response = callback(request, **param_dict)
File "/Users/nesh/devel/django/django/views/admin/main.py", line 211, in change_list filter_template.append('%r\n' % \ AttributeError: 'Package' object has no attribute 'id'

Attachments (0)

Change History (3)

comment:1 Changed 9 years ago by Yoan Blanc

Error is with Many-to-many fields.

django/views/admin/main.py : lines 920, 922 too

Why not adding a __id__ method that returns self.id by default and, for example, self.myId when specified ?

comment:2 Changed 9 years ago by adrian

  • Status changed from new to assigned

comment:3 Changed 9 years ago by adrian

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

Fixed in [654].

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.