I solved it! The problem was because I was trying to sort by a field that was not listed on Admin.list_display
Updated code: class Model(models.Model): opis = models.CharField(maxlength=50) znamka = models.ForeignKey(Znamka) def __str__(self): return "%s %s" % (self.znamka, self.opis) class Admin: list_filter = ['znamka'] # sidebar with handy filters list_display = ('znamka', 'opis') class Meta: verbose_name_plural = "Modeli" ordering = ['znamka','opis'] Like a charm, it works. =) On 7/13/06, Carlos Yoder <[EMAIL PROTECTED]> wrote: > >> class Item(models.Model): > > > name = models.Charfield(maxlength=100) > > > user = models.ForeignKey(User) > > > > > > def get_user_name(self): > > > return self.user.name > > > > > > class Admin: > > > list_display = ('name', 'get_user_name') > > > ordering = ('get_user_name', 'name') > > > > Hi Mikael, > > > > You can't order by the result of a Python function, because the > > ordering clause happens at the SQL level, not in Python. > > > How about ordering by a ForeignKeyField? > > snippet follows: > > class Model(models.Model): > opis = models.CharField(maxlength=50) > znamka = models.ForeignKey(Znamka) > > def __str__(self): > return "%s %s" % (self.znamka, self.opis) > > class Admin: > list_filter = ['znamka'] # > sidebar with handy filters > > class Meta: > verbose_name_plural = "Modeli" > ordering = ['znamka', 'opis'] > > > In the memorable words of Dr. Jones... "this doesn't seem to work" =) > > Regards, > > > -- > Carlos Yoder > http://carlitosyoder.blogspot.com > -- Carlos Yoder http://carlitosyoder.blogspot.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---