Opened 19 years ago

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

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'

Change History (3)

comment:1 by Yoan Blanc, 19 years ago

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 by Adrian Holovaty, 19 years ago

Status: newassigned

comment:3 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: assignedclosed

Fixed in [654].

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