Has anyone got this working? Or any other way of ordering items in the
admin interface by foreign key? I get error messages in the admin
interface with the example below, as far as I can tell it is like the
manual.
Example from manual:
class Answer(models.Model):
question = models.ForeignKey(Question)
# ...
class Meta:
order_with_respect_to = 'question'
My code:
# articles, sub blocks within the sections
class Article( models.Model ):
name = models.CharField(maxlength=100)
section = models.ForeignKey(Section)
headline = models.CharField(maxlength=200, blank=True, null=True,
default='' )
body = models.TextField( blank=True, null=True, default='' )
order = models.IntegerField(default=0)
date = models.DateField(blank=True, null=True, default='')
visible = models.BooleanField(default=True)
def __str__(self):
return "%s - %s" % ( self.section, self.name )
class Admin: pass
class Meta:
order_with_respect_to = 'section'
ordering = [ '-date', 'order']
verbose_name_plural = 'Articles'
Thanks
Iain
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---