devfzn
fa10284b72
Editados settings.py y urls.py del sitio para app y uso de token. Implementación de token para app ecommerce en ruta /api-token-auth, uso de clase Token del rest_framework y signals de Django, para creación de token post-save.
10 lines
343 B
Python
10 lines
343 B
Python
from django.db.models.signals import post_save
|
|
from django.dispatch import receiver
|
|
from django.contrib.auth.models import User
|
|
from rest_framework.authtoken.models import Token
|
|
|
|
@receiver(post_save, sender=User, weak=False)
|
|
def report_uploaded(sender, instance, created, **kwargs):
|
|
if created:
|
|
Token.objects.create(user=instance)
|