summaryrefslogtreecommitdiff
path: root/tests/ordering/models.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2014-04-26 03:34:20 -0400
committerSimon Charette <charette.s@gmail.com>2014-04-30 14:26:39 -0400
commita6ecd5dbb34249f756a337c359eef1e8d78dc01e (patch)
treebe80a1387b8541e07db3da89e0d774597dffbfe5 /tests/ordering/models.py
parent1084456ac2e707fc562906e95ad78f409dcc9325 (diff)
[1.7.x] Fixed #19195 -- Allow explicit ordering by a relation `_id` field.
Thanks to chrisedgemon for the report and shaib, akaariai and timgraham for the review. Backport of 24ec9538b7 from master
Diffstat (limited to 'tests/ordering/models.py')
-rw-r--r--tests/ordering/models.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/tests/ordering/models.py b/tests/ordering/models.py
index 415b28bb41..2ab16f3c5f 100644
--- a/tests/ordering/models.py
+++ b/tests/ordering/models.py
@@ -17,25 +17,19 @@ from django.db import models
from django.utils.encoding import python_2_unicode_compatible
-@python_2_unicode_compatible
-class Article(models.Model):
- headline = models.CharField(max_length=100)
- pub_date = models.DateTimeField()
-
+class Author(models.Model):
class Meta:
- ordering = ('-pub_date', 'headline')
-
- def __str__(self):
- return self.headline
+ ordering = ('-pk',)
@python_2_unicode_compatible
-class ArticlePKOrdering(models.Model):
+class Article(models.Model):
+ author = models.ForeignKey(Author, null=True)
headline = models.CharField(max_length=100)
pub_date = models.DateTimeField()
class Meta:
- ordering = ('-pk',)
+ ordering = ('-pub_date', 'headline')
def __str__(self):
return self.headline