Last active
August 11, 2019 23:06
-
-
Save rayashi/23e3e04957f96b86fdc80fe2ad08ee44 to your computer and use it in GitHub Desktop.
Catching post_save signal to create a token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.db.models.signals import post_save | |
from django.dispatch import receiver | |
from rest_framework.authtoken.models import Token | |
@receiver(post_save, sender=settings.AUTH_USER_MODEL) | |
def create_auth_token(sender, instance=None, created=False, **kwargs): | |
if created: | |
Token.objects.create(user=instance) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment