/tests/modeltests/order_with_respect_to/models.py
Python | 29 lines | 17 code | 9 blank | 3 comment | 0 complexity | 5ff40a4729a1dd570954bf3133c4c69f MD5 | raw file
1""" 2Tests for the order_with_respect_to Meta attribute. 3""" 4 5from django.db import models 6 7 8class Question(models.Model): 9 text = models.CharField(max_length=200) 10 11class Answer(models.Model): 12 text = models.CharField(max_length=200) 13 question = models.ForeignKey(Question) 14 15 class Meta: 16 order_with_respect_to = 'question' 17 18 def __unicode__(self): 19 return unicode(self.text) 20 21class Post(models.Model): 22 title = models.CharField(max_length=200) 23 parent = models.ForeignKey("self", related_name="children", null=True) 24 25 class Meta: 26 order_with_respect_to = "parent" 27 28 def __unicode__(self): 29 return self.title