mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-16 20:00:23 +00:00
Fix _clone signature for Django<1.9
InheritanceQuerySetMixin._clone signature conflicts with django ValuesQuerySet._clone code which calls super like this: "c = super(ValuesQuerySet, self)._clone(klass, **kwargs)"
This commit is contained in:
parent
b06fa8c752
commit
ce8deed5ca
3 changed files with 10 additions and 1 deletions
|
|
@ -35,4 +35,5 @@ sayane
|
|||
Tony Aldridge <zaragopha@hotmail.com>
|
||||
Travis Swicegood <travis@domain51.com>
|
||||
Trey Hunner <trey@treyhunner.com>
|
||||
Karl Wan Nan Wo <karl.wnw@gmail.com>
|
||||
zyegfryed
|
||||
|
|
|
|||
|
|
@ -53,10 +53,13 @@ class InheritanceQuerySetMixin(object):
|
|||
new_qs.subclasses = subclasses
|
||||
return new_qs
|
||||
|
||||
def _clone(self, **kwargs):
|
||||
def _clone(self, klass=None, setup=False, **kwargs):
|
||||
for name in ['subclasses', '_annotated']:
|
||||
if hasattr(self, name):
|
||||
kwargs[name] = getattr(self, name)
|
||||
if django.VERSION < (1, 9):
|
||||
kwargs['klass'] = klass
|
||||
kwargs['setup'] = setup
|
||||
return super(InheritanceQuerySetMixin, self)._clone(**kwargs)
|
||||
|
||||
def annotate(self, *args, **kwargs):
|
||||
|
|
|
|||
|
|
@ -763,6 +763,11 @@ class InheritanceManagerTests(TestCase):
|
|||
set(expected_related_names))
|
||||
|
||||
|
||||
def test_filter_on_values_queryset(self):
|
||||
queryset = InheritanceManagerTestChild1.objects.values('id').filter(pk=self.child1.pk)
|
||||
self.assertEqual(list(queryset), [{'id': self.child1.pk}])
|
||||
|
||||
|
||||
class InheritanceManagerUsingModelsTests(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue