diff options
Diffstat (limited to 'tests/custom_managers')
| -rw-r--r-- | tests/custom_managers/models.py | 7 | ||||
| -rw-r--r-- | tests/custom_managers/tests.py | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/custom_managers/models.py b/tests/custom_managers/models.py index 318059a037..5607c11dd0 100644 --- a/tests/custom_managers/models.py +++ b/tests/custom_managers/models.py @@ -66,6 +66,12 @@ class BaseCustomManager(models.Manager): CustomManager = BaseCustomManager.from_queryset(CustomQuerySet) +class CustomInitQuerySet(models.QuerySet): + # QuerySet with an __init__() method that takes an additional argument. + def __init__(self, custom_optional_arg=None, model=None, query=None, using=None, hints=None): + super(CustomInitQuerySet, self).__init__(model=model, query=query, using=using, hints=hints) + + class DeconstructibleCustomManager(BaseCustomManager.from_queryset(CustomQuerySet)): def __init__(self, a, b, c=1, d=2): @@ -99,6 +105,7 @@ class Person(models.Model): custom_queryset_default_manager = CustomQuerySet.as_manager() custom_queryset_custom_manager = CustomManager('hello') + custom_init_queryset_manager = CustomInitQuerySet.as_manager() def __str__(self): return "%s %s" % (self.first_name, self.last_name) diff --git a/tests/custom_managers/tests.py b/tests/custom_managers/tests.py index 0412a423aa..b8acfc906d 100644 --- a/tests/custom_managers/tests.py +++ b/tests/custom_managers/tests.py @@ -597,3 +597,12 @@ class CustomManagersRegressTestCase(TestCase): obj = RelatedModel.objects.get(name="xyzzy") obj.delete() self.assertEqual(len(OneToOneRestrictedModel.plain_manager.all()), 0) + + def test_queryset_with_custom_init(self): + """ + BaseManager.get_queryset() should use kwargs rather than args to allow + custom kwargs (#24911). + """ + qs_custom = Person.custom_init_queryset_manager.all() + qs_default = Person.objects.all() + self.assertQuerysetEqual(qs_custom, qs_default) |
