-
-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InheritanceManagerMixin get_queryset not work with Manager.from_queryset [Django 1.9] #205
Comments
Hi, If you're not using the latest version, please try upgrading it to see if that resolves your issue. If you are using the latest version and it isn't working, please provide a minimal example of your code so it can be demonstrated how the previous fix missed a use-case. |
Closing pending more information. |
@kezabelle kezabelle
So I tried to fix this issue.
|
What version of django-model-utils? |
The version is |
Your proposed "fix" would turn If you need to combine |
I am sorry that I just uploaded my sample source code by ZIP file. Could you please see below code? This custom manger Please point out my code, when I misuse |
I see. The key information I was missing was that you are using You can still make it work as-is, if you (as mentioned above) explicitly "return an instance of your own custom QuerySet class" from your But I would accept a PR to update |
It is better to explicitly return an instance of custom QuerySet class instead of calling |
Since QuerySet._clone() has been changed at Djang 1.9,
django/django@4c3bfe9#diff-5b0dda5eb9a242c15879dc9cd2121379R1043
InheritanceManagerMixin get_queryset always returns InheritanceQuerySet() because there is no 'klass'.
[Django < 1.9]
"c = klass(model=self.model, query=query, using=self._db, hints=self._hints)" clones new my Managers QuerySet.
However, at [Django 1.9]
"clone = self.class(model=self.model, query=query, using=self._db, hints=self._hints)" always clones InheritanceQuerySet.
So my Manager.from_queryset does not adapt.
The text was updated successfully, but these errors were encountered: