User Profile minimal code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# -*- coding: utf-8 -*-
from django.contrib.auth.models import User
from django.db import models

class UserProfile(models.Model):
    ''' Special User for Ionyse '''
    user = models.ForeignKey(User, unique=True)

def createUserProfile(sender, instance, **kwargs):
    """ Create a UserProfile object each time a User is created ; and
    link it.
    """
    UserProfile.objects.get_or_create(user=instance)

models.signals.post_save.connect(createUserProfile, sender=User)

More like this

  1. create_model_instances management command by Lacrymology 4 months, 4 weeks ago
  2. Improved User Admin by gregb 3 years, 1 month ago
  3. Alternative to User.get_profile() by jpwatts 5 years, 3 months ago
  4. convenience parent class for UserProfile model by willhardy 4 years, 1 month ago
  5. Effective content caching for mass-load site using redirect feature by nnseva 1 year, 11 months ago

Comments

(Forgotten your password?)