[Answered ]-IntegrityError -userprofile.u_id may not be NULL, django user registration

2👍

From Django Docs:

https://docs.djangoproject.com/en/1.4/ref/models/fields/

Field.unique

If True, this field must be unique throughout the table.

This is enforced at the database level and by model validation. If you
try to save a model with a duplicate value in a unique field, a
django.db.IntegrityError will be raised by the model’s save() method.

This option is valid on all field types except ManyToManyField and
FileField.

You are telling UserProfiles that the UserProfiles.u_id is unique, it’s not (blanks/null). So you’re getting the error. You may want to consider changing u_id to be a AutoField primary_key. And then connect them using models.ForeignKey(‘UserBase’)

Leave a comment