jeudi 4 décembre 2014

Django UserProfile not created


Vote count:

0




I'd like django 1.7 to automatically create a UserProfile instance for each newly registered user. So in models I have:



class UserProfile(models.Model):
username = models.OneToOneField(User)
name = models.CharField(max_length=30)
occupation = models.CharField(max_length=50)
city = models.CharField(max_length=30)


@models.permalink
def get_absolute_url(self):
return ('view_pirate', None, {'username': self.account.user})

def __unicode__(self):
return unicode(self.username)

#**this line is supposed to create user profile****
User.profile = property(lambda u:UserProfile.objects.get_or_create(username=u)[0])


But when I check the database no new row in userprofile_userprofile is created after a new user registration. What is wrong here?



asked 21 secs ago







Django UserProfile not created

Aucun commentaire:

Enregistrer un commentaire