spradio-server-django/savepointradio/profiles/signals.py
2018-01-19 11:26:14 -05:00

14 lines
440 B
Python

from django.conf import settings
from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import RadioProfile
@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_profile(sender, instance, created, **kwargs):
"""
Create a profile object after a new user is created and link them.
"""
if created:
profile, new = RadioProfile.objects.get_or_create(user=instance)