#7112 closed (invalid)
Ordering in admin breaks changelist
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | 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 have a very simple model :
class Forum(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField()
parent = models.ForeignKey('self', blank=True, null=True, related_name='child')
description = models.TextField()
threads = models.IntegerField(default=0)
posts = models.IntegerField(default=0)
class Admin:
ordering = ['parent','title']
Since the qsrf branch was merged, I can add new forums, but the lists of forums when viewing the changelist is empty. The total number of forums reported at the changelist footer is correct though. I am running revision 7501 with a mysql backend. If I replace the ordering with a simple 'pass' everything is fine, although the list is not ordered as I wanted it.
Change History (4)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Investigating a bit more, it's the ordering by the self referential foreignkey that breaks things.
comment:3 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
From Malcolm:
That code was already broken, but you just hadn't noticed. Django is now correctly reporting the error. If you order by the parent, then the parents should be order by their parents and so on. Since that's impossible to encode in SQL, previous versions of Django were returning only a single level of ordering, which was very inconsistent.
Either remove the infinite loop or use order_by('parentid') if you want a workaround to simulate the previous ambiguous behaviour.
Sorry, should have previewed that... Here's the model again.