I'm using djangorestframework in django==2.0 with python 3.7
I put an event like this
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs):
if created:
from rest_framework.authtoken.models import Token
Token.objects.create(user=instance)
when I tried to create a user the compiler giving an error:
Exception Value:
type object 'Token' has no attribute 'objects'
Try to do the following
>>> from rest_framework.authtoken.models import Token
>>> Token.objects.all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: type object 'Token' has no attribute 'objects'
If the above error occurs, That's because you didn't add the auth token in the settings' INSTALLED_APPS. if it's not the in the INSTALLED_APPS, it's abstract and doesn't have the default manager (objects).
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