mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #7371 -- Fixed an edge case when ordering on related models.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7786 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -172,6 +172,17 @@ class Child(models.Model):
|
||||
person = models.OneToOneField(Member, primary_key=True)
|
||||
parent = models.ForeignKey(Member, related_name="children")
|
||||
|
||||
# Custom primary keys interfered with ordering in the past.
|
||||
class CustomPk(models.Model):
|
||||
name = models.CharField(max_length=10, primary_key=True)
|
||||
extra = models.CharField(max_length=10)
|
||||
|
||||
class Meta:
|
||||
ordering = ['name', 'extra']
|
||||
|
||||
class Related(models.Model):
|
||||
custom = models.ForeignKey(CustomPk)
|
||||
|
||||
|
||||
__test__ = {'API_TESTS':"""
|
||||
>>> t1 = Tag.objects.create(name='t1')
|
||||
@@ -786,5 +797,9 @@ Bug #7277
|
||||
>>> n1.annotation_set.filter(Q(tag=t5) | Q(tag__children=t5) | Q(tag__children__children=t5))
|
||||
[<Annotation: a1>]
|
||||
|
||||
Bug #7371
|
||||
>>> Related.objects.order_by('custom')
|
||||
[]
|
||||
|
||||
"""}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user