Closed doctorallen closed 6 years ago
That's because you didn't add the auth token in the settings' INSTALLED_APPS
Edit: if it's not the in the INSTALLED_APPS
, it's abstract and doesn't have the default manager (objects
).
@xordoquy Thank you!
Add 'rest_framework.authtoken'
to INSTALLED_APPS list in settings.py
Add
'rest_framework.authtoken'
to INSTALLED_APPS list in settings.py Don't forget to run apython manage.py migrate
after making changes in your settings file
This comment solved my problem, 4 years later. Thanks!
thank you @xordoquy
I have tried all the steps above but still this error is popping TypeError at /login/ Object of type method is not JSON serializable
still returns rest_framework.authtoken.models.Token.DoesNotExist: Token matching query does not exist. after adding authtoken in 'INSTALLED_APPS'
traceback shows self.token = Token.objects.get(user=self.user) is that a bad way to get token.objects?
rest_framework.authtoken
thank you :)
thanks you
still returns rest_framework.authtoken.models.Token.DoesNotExist: Token matching query does not exist. after adding authtoken in 'INSTALLED_APPS'
traceback shows self.token = Token.objects.get(user=self.user) is that a bad way to get token.objects?
did u find a way to solve this I'm using a custom user and I guess its the problem :/
I'm trying to implement my own serializer and view to handle Token based authentication with email instead of username. In copying the ObtainAuthToken view, an error is returned about the
Token
object not having theobjects
attribute.Steps to reproduce
mkdir restframework
cd restframework/
virtualenv env
source env/bin/activate
pip install django
pip install djangorestframework
django-admin startproject tutorial
cd tutorial
python manage.py shell
Expected behavior
Token class can query objects
Actual behavior
This class (being a django model) should be able to query using the
objects
attribute, should it not?