This is a followup of https://github.com/encode/django-rest-framework/pull/7341#issuecomment-666108668 discussion
Token become abstract if rest_framework.authtoken not in settings.INSTALLED_APPS . For example django-rest-auth imports rest_framework.authtoken.models.Token as default value but if project provides its own token model then rest_framework.authtoken not required in INSTALLED_APPS. Same thing will happen if someone needs a CustomToken that extends Token in that case he wants Token model to be abstract.
master branch of Django REST framework.Import rest_framework.authtoken.models while 'rest_framework.authtoken' not in settings.INSTALLED_APPS.
Thanks @kalekseev!
First guess, making TokenProxy proxy depend on whether 'rest_framework.authtoken' is installed (to mirror the Token abstract behaviour) should™ solve this... 😬
proxy = 'rest_framework.authtoken' in settings.INSTALLED_APPS
First guess, making
TokenProxyproxydepend on whether'rest_framework.authtoken'is installed (to mirror theTokenabstractbehaviour) should™ solve this... 😬proxy = 'rest_framework.authtoken' in settings.INSTALLED_APPS
TokenProxy should be abstract too
proxy = 'rest_framework.authtoken' in settings.INSTALLED_APPS
abstract = 'rest_framework.authtoken' not in settings.INSTALLED_APPS
A radical solution could be:
if 'rest_framework.authtoken' in settings.INSTALLED_APPS:
class TokenProxy:
...
I m facing same issue while deploying the qeb app to ec2 instance, can someone tell wat is the solution? I have used djoser module for authentication
I basically arrived at the if/else solution suggested above and I submitted it for review. I think right now either #7571 or #7584 will fix the issue if anyone needs a quick fix and doesn't want to add authtoken into their installed apps.
Still facing this error while using djoser.
Had to add rest_framework.authtoken in INSTALLED_APPS
I'm also facing this issue, after upgrading from 3.11.0. The error is Abstract base class containing model fields not permitted for proxy model 'TokenProxy'., which is triggered by https://github.com/st4lk/django-rest-social-auth/blob/996a1c5f431defac8d5def96683ad1413499ec2e/rest_social_auth/serializers.py#L6
Adding rest_framework.authtoken in INSTALLED_APPS does not help. Is there anything that other packages, like rest_social_auth, need to change to make it work?
My specific error message is on #7561, which is marked as duplicate to this issue.
Most helpful comment
I'm also facing this issue, after upgrading from 3.11.0. The error is
Abstract base class containing model fields not permitted for proxy model 'TokenProxy'., which is triggered by https://github.com/st4lk/django-rest-social-auth/blob/996a1c5f431defac8d5def96683ad1413499ec2e/rest_social_auth/serializers.py#L6Adding
rest_framework.authtokeninINSTALLED_APPSdoes not help. Is there anything that other packages, like rest_social_auth, need to change to make it work?My specific error message is on #7561, which is marked as duplicate to this issue.