[Answered ]-Django.db.utils.IntegrityError: null value in column "auto_id" of relation "university_university" violates not-null constraint

1👍

As the error says, you have a null value in the ID column.

auto_id = models.PositiveIntegerField(db_index=True, unique=True)

You have PositiveIntegerField, that means that you have to fill it and you’re probably not doing that in forms. For ID you should always use AutoField.

So it returns null because there is nothing in your auto_id variable. I think replace this with AutoField should solve the problem.

Documentation search for AutoField:
https://docs.djangoproject.com/en/4.1/ref/models/fields/

👤Maro

Leave a comment