when i try to create superuser from shell or via manage.py or from Django-Admin page ; it throws error like :
IntegrityError at /admin/auth/user/add/
null value in column "link_karma" violates not-null constraint
Here is my models.py [User Part]:
class User_Profile(models.Model):
user = models.OneToOneField(User)
link_karma = models.IntegerField()
comment_karma = models.IntegerField()
avatar = models.CharField(max_length=100)
def create_user_profile(sender,instance,created,**kwargs):
if created:
User_Profile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
def __unicode__(self):
return self.user.username
i added fallowing line in to settings.py:
AUTH_PROFILE_MODULE = 'accounts.User_Profile'
before add this line ; it was the same.
Note : i tried to change type of link_karma field to CharField. it is same.
Note : If any additional data needed ; i can add it.
Try setting
blank=True, null=Truefor bothlink_karmaandcomment_karma. You’re not passing any values to those fields so when your create statement tries to create the object, it doesn’t know what to givelink_karmhence the error.As goliney correctly pointed out, you dont need email in your User_Profile model as User already has it.