In my rest_framework settings I set SessionAuthentication as the default authentication class
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
)
The problem is that my User DELETE api view tries to collapse delete on the authtoken_token table, which doesn't exist (since I don't need it), raising a database exception.
Specifically, when obj.delete() is invoked in DestroyModelMixin.destroy, this exception is raised:
DatabaseError: relation "authtoken_token" does not exist
LINE 1: ...oken"."user_id", "authtoken_token"."created" FROM "authtoken...
Is one required to syncdb rest_framework's models, even if one doesn't need them?
Is there a way to use SessionAuthentication without including authtoken.models?
Am I doing something wrong?
(removing authtoken.models.Token completely from rest_framework/authentication.py seems to solve the problem)
Here's the root cause...
https://code.djangoproject.com/ticket/19422
Will sort out a workaround in the meantime, which will probably just involve making sure Token doesn't get imported anywhere unless rest_framework.authtoken is in INSTALLED_APPS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With