Hello, I have a category model with a self foreign key:
class Category(models.Model):
title = models.CharField(max_length=100)
parent = models.ForeignKey('self', blank=True, null=True,
related_name = 'childs')
def __unicode__(self):
if not self.parent:
return self.title
else:
return self.parent.__unicode__() + u'/' + self.title
I want to order (in admin and in querysets) categories with respect to
the result of my __unicode__
function (ex: /cat1/cat4 < /cat2/cat3). I tried ordering option in
CategoryAdmin, Meta class with ordering
but nothing worked ... May I add a __cmp__ function somewhere ?
--
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.