User post_save signal to auto create 'admin' profile

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# SIGNALS AND LISTENERS
from django.contrib.auth.models import User
from django.db.models import signals
from django.dispatch import dispatcher

# User
def user_post_save(sender, instance, signal, *args, **kwargs):
    # Creates user profile
    profile, new = UserProfile.objects.get_or_create(user=instance)

dispatcher.connect(user_post_save, signal=signals.post_save, sender=User)

Comments

(Forgotten your password?)

You may use Markdown syntax here, but raw HTML will be removed.