-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fix: authtoken.TokenProxy cannot be proxy when not installed #7442 #7571
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
Fix: authtoken.TokenProxy cannot be proxy when not installed #7442 #7571
Conversation
I arrived independently at the other solution @kalekseev proposed. Either is probably fine to use from my point of view since I don't use the model and may not ever, but I think my solution of throwing |
importlib.reload(rest_framework.authtoken.models) | ||
# Set the proxy and abstract properties back to the version, | ||
# where authtoken is among INSTALLED_APPS. | ||
importlib.reload(rest_framework.authtoken.models) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is the solution that's picked, you may want to edit this to check that the two models do exist and that they are indeed abstract instead of just checking that the import works. That way if Django's implementation changes we'd be able to notice the difference and either remove the test or special case it depending on the supported version.
Either way, nice to have a test! I started searching for issues before writing a test and this will help me too 🙂
# Set the proxy and abstract properties back to the version, | ||
# where authtoken is among INSTALLED_APPS. | ||
importlib.reload(rest_framework.authtoken.models) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you probably want to put the final reload in a finally:
block, that way the imports aren't messed up for a subsequent test. I ran into this issue while adding tests to my PR.
This seems to be sufficient to me, let's go with this. |
When do you expect a new release that will include this fix? |
Can we get a git tag added for this version and a release updated on pypi? https://pypi.org/project/djangorestframework/ Still shows 3.12.1 as being the latest. |
I'm also eagerly awaiting the PyPi publish. Thanks for the fix! |
@naggie @sdebnath Here's a line for your
|
Thanks @banagale - looking forward to the distribution update down the road. |
Used the first of solutions @kalekseev proposed in #7442 (comment)