I’m trying to use the User profile feature so here is my profile model:
class Nuser(models.Model):
user = models.OneToOneField(User)
initials = models.CharField(max_length=5)
def __unicode__(self):
return u'%s %s' % (self.first_name, self.last_name)
def create_user_profile(sender, instance, created, **kwargs):
if created:
Nuser.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
My models are correctly created but if I try to add a user with the admin interface I get this error:
IntegrityError at /admin/auth/user/add/
(1062, "Duplicate entry ‘3’ for key ‘user_id’")
Am I doing something wrong ?
The signal is probably being registered more than once. Use the
dispatch_uidargument to prevent this.For example: