mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #14471 -- Corrected a regression in the use of methods on custom managers on related querysets. Thanks to Lucky for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14389 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -891,6 +891,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
|
||||
|
||||
Reference in New Issue
Block a user