1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #19195 -- Allow explicit ordering by a relation _id field.

Thanks to chrisedgemon for the report and shaib, akaariai and
timgraham for the review.
This commit is contained in:
Simon Charette
2014-04-26 03:34:20 -04:00
parent a5f6cbce07
commit 24ec9538b7
5 changed files with 115 additions and 52 deletions

View File

@@ -17,8 +17,14 @@ from django.db import models
from django.utils.encoding import python_2_unicode_compatible
class Author(models.Model):
class Meta:
ordering = ('-pk',)
@python_2_unicode_compatible
class Article(models.Model):
author = models.ForeignKey(Author, null=True)
headline = models.CharField(max_length=100)
pub_date = models.DateTimeField()
@@ -27,15 +33,3 @@ class Article(models.Model):
def __str__(self):
return self.headline
@python_2_unicode_compatible
class ArticlePKOrdering(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateTimeField()
class Meta:
ordering = ('-pk',)
def __str__(self):
return self.headline