mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #13296 -- Fixed ordering by Options.order_with_respect_to after deleting objects.
Thanks Simon Meers for the original patch.
This commit is contained in:
committed by
Mariusz Felisiak
parent
d9881a025c
commit
f97bbad908
@@ -87,3 +87,17 @@ class BaseOrderWithRespectToTests:
|
||||
self.Post.objects.create(title="2.1", parent=p2)
|
||||
p1_3 = self.Post.objects.create(title="1.3", parent=p1)
|
||||
self.assertSequenceEqual(p1.get_post_order(), [p1_1.pk, p1_2.pk, p1_3.pk])
|
||||
|
||||
def test_delete_and_insert(self):
|
||||
q1 = self.Question.objects.create(text='What is your favorite color?')
|
||||
q2 = self.Question.objects.create(text='What color is it?')
|
||||
a1 = self.Answer.objects.create(text='Blue', question=q1)
|
||||
a2 = self.Answer.objects.create(text='Red', question=q1)
|
||||
a3 = self.Answer.objects.create(text='Green', question=q1)
|
||||
a4 = self.Answer.objects.create(text='Yellow', question=q1)
|
||||
self.assertSequenceEqual(q1.answer_set.all(), [a1, a2, a3, a4])
|
||||
a3.question = q2
|
||||
a3.save()
|
||||
a1.delete()
|
||||
new_answer = self.Answer.objects.create(text='Black', question=q1)
|
||||
self.assertSequenceEqual(q1.answer_set.all(), [a2, a4, new_answer])
|
||||
|
||||
Reference in New Issue
Block a user