1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

[1.2.X] Fixed #14471 -- Corrected a regression in the use of methods on custom managers on related querysets. Thanks to Lucky for the report.

Backport of r14389 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14390 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2010-10-28 13:00:08 +00:00
parent 3a679cc1c4
commit 29ea1bef21
3 changed files with 40 additions and 5 deletions

View File

@@ -890,6 +890,28 @@ class QueryTestCase(TestCase):
except ValueError:
pass
def test_related_manager(self):
"Related managers return managers, not querysets"
mark = Person.objects.using('other').create(name="Mark Pilgrim")
# extra_arg is removed by the BookManager's implementation of
# create(); but the BookManager's implementation won't get called
# unless edited returns a Manager, not a queryset
mark.book_set.create(title="Dive into Python",
published=datetime.date(2009, 5, 4),
extra_arg=True)
mark.book_set.get_or_create(title="Dive into Python",
published=datetime.date(2009, 5, 4),
extra_arg=True)
mark.edited.create(title="Dive into Water",
published=datetime.date(2009, 5, 4),
extra_arg=True)
mark.edited.get_or_create(title="Dive into Water",
published=datetime.date(2009, 5, 4),
extra_arg=True)
class TestRouter(object):
# A test router. The behaviour is vaguely master/slave, but the