Skip to content

Instantly share code, notes, and snippets.

@bohde
Created March 3, 2011 17:55
Show Gist options
  • Save bohde/853179 to your computer and use it in GitHub Desktop.
Save bohde/853179 to your computer and use it in GitHub Desktop.
Auto Create a User Profile
from django.contrib.auth.models import User
from django.db import models
class Profile(models.Model):
user = models.OneToOneField(User)
silly_field = models.CharField(max_length=255, default="Silly")
def auto_create_profile(sender, instance, created, **kwargs):
if created:
user.profile, created = Profile.objects.get_or_create(user=instance)
models.signals.post_save.connect(auto_create_profile, sender=User)
@Allan-Nava
Copy link

How can I pass the kwargs as parameters in auto_create_profile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment