mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #13241. order_with_respect_to now works with ForeignKeys who refer to their model lazily (i.e. with a string). Thanks to Gabriel Grant for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14045 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -2,7 +2,7 @@ from operator import attrgetter
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from models import Question, Answer
|
||||
from models import Post, Question, Answer
|
||||
|
||||
|
||||
class OrderWithRespectToTests(TestCase):
|
||||
@@ -60,3 +60,12 @@ class OrderWithRespectToTests(TestCase):
|
||||
],
|
||||
attrgetter("text")
|
||||
)
|
||||
|
||||
def test_recursive_ordering(self):
|
||||
p1 = Post.objects.create(title='1')
|
||||
p2 = Post.objects.create(title='2')
|
||||
p1_1 = Post.objects.create(title="1.1", parent=p1)
|
||||
p1_2 = Post.objects.create(title="1.2", parent=p1)
|
||||
p2_1 = Post.objects.create(title="2.1", parent=p2)
|
||||
p1_3 = Post.objects.create(title="1.3", parent=p1)
|
||||
self.assertEqual(p1.get_post_order(), [p1_1.pk, p1_2.pk, p1_3.pk])
|
||||
|
||||
Reference in New Issue
Block a user