Skip to content

Instantly share code, notes, and snippets.

@spmurrayzzz
Created February 20, 2013 23:21
Show Gist options
  • Save spmurrayzzz/5000634 to your computer and use it in GitHub Desktop.
Save spmurrayzzz/5000634 to your computer and use it in GitHub Desktop.
Extending Django User model
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
# ------------- USERS -------------
class UserProfile(models.Model):
user = models.OneToOneField(User)
def __unicode__(self):
return "%s's profile" % self.user
def create_user_profile(sender, instance, created, **kwargs):
if created:
profile, created = UserProfile.objects.get_or_create(user=instance)
post_save.connect(create_user_profile, sender=User)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment