I'm trying to group items in the Admin interface based on a foreign
key, and I'm hitting a few stumbling blocks.
Simplified objects are...
> class MenuItem(models.Model):
> name = models.CharField(maxlength=200)
>
> class Page(models.Model):
> name = models.CharField(maxlength=200)
> menu_item = models.ForeignKey('MenuItem', blank=True, null=True)
>
> class Meta:
> ordering = ('menu_item_id')
What I want is on the "Page" admin screen to display the objects in
the order of their related MenuItems.
I managed to get this to work, using the above argument of
'menu_item_id', but manage.py gives the following error:
> Error: Couldn't install apps, because there were errors in one or
> more models:
> pages.page: "ordering" refers to "menu_item_id", a field that
> doesn't exist.
If I tried ordering = ('menu_item') then the Admin interface bombed
out due to broken SQL - the ORDER BY referenced the menu_item table
but it was not in the FROM clause.
I considered the 'order_with_respect_to' option, but it would appear
to serve some other function (although I'm not sure exactly what that
is...)
So, my questions a) Is this a bug or am I missing something and b) If
this is a bug would the correct solution be to patch the manager to
accept _id in ordering or patch the SQL query to use the correct tables?
Thanks,
James
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---