Opened 19 years ago
Closed 18 years ago
#520 closed defect (worksforme)
Ordering via foreign key causes multiple display of entries in Admin view
Reported by: | andreas | 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
Ordering via foreign key causes multiple display of entries in Admin view.
For instance:
class ParentClass(meta.Model): somevar = meta.CharField(maxlength=100) def __repr__(self): return self.somevar class META: admin = meta.Admin() ordering = ['somevar'] class FirstChild(meta.Model): theparent = meta.ForeignKey(ParentClass) myvar = meta.CharField(maxlength=100) def __repr__(self): return repr(self.get_theparent()) + "-" + self.myvar class META: admin = meta.Admin() ordering = ['theparent']
After entering two ParentClasses, parent1 and parent2, and two FirstChilds of parent1, child1 and child2, the Admin "First childs" view looks like this:
First child parent1-child2 parent1-child1 parent1-child2 parent1-child1 2 first childs
Workaround: Add list_display-option:
class FirstChild(meta.Model): ... class META: admin = meta.Admin(list_display = ('myvar', 'theparent')) ordering = ['theparent']
Note:
See TracTickets
for help on using tickets.