The solution to these issues was found by digging around in the SQLite DB, as suggested here.
The manage.py sqlall
command showed the below, where the model's hidden id
field that Django automatically creates is specified as a PRIMARY KEY
.
BEGIN;
CREATE TABLE "profiles_specialist" (
"id" integer NOT NULL PRIMARY KEY,
"user_id" integer NOT NULL REFERENCES "auth2_customuser" ("id"),
The hidden id
field had lost its PK status somehow, and was set only as an INTEGER
that was failing to auto increment itself each time a new object was saved.
This field needed to be reset to INTEGER PRIMARY KEY
, and everything then worked perfectly.