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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user