I have a non-primary key integer field in my Django model and I use Postgresql for database.
class TestModel(models.Model)
pid = models.IntegerField(blank=True)
some_field = models.CharField()
I want my pid field to have default values, that appear in database, I set the serial type for the pid field on the DB side
alter column pid type serial not null;
but when I create some record without without specifying value for pid, Django gives an error "null value in column "pid" violates not-null constraint", although it works fine when inserting data via SQL directly into database. I found this Django and PostgreSQL sequence for primary key autoincrement, but it's not working for me