I renamed some of my models and tried to apply the migrations, but Django didn't detect that they were renamed. Therefore I deleted the content of manage.py, flushed the db and then ran manage.py makemigrations and manage.py migrate. Now I get the following error when I try to access one of my models via admin console or via any queries:
ProgrammingError at /admin/restapi/appuser/
relation "restapi_appuser" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "restapi_appuser"
When I ran manage.py makemigrations the output included (truncated):
Migrations for 'restapi':
restapi/migrations/0001_initial.py
- Create model AppUser
I tried to run python3 manage.py sqlmigrate restapi 0001_initial with the following output (truncated):
BEGIN;
--
-- Create model AppUser
--
CREATE TABLE "restapi_appuser" ("id" serial NOT NULL PRIMARY KEY, "username" varchar(30) NOT NULL UNIQUE, "email" varchar(50) NOT NULL UNIQUE, "password" varchar(50) NOT NULL, "join_date" timestamp with time zone NOT NULL);
It seems to me like the model should be in the database, but I am wondering why I am getting this error
edit:
here the output of manage.py migrate for completeness:
> python3 manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, restapi, sessions
Running migrations:
No migrations to apply.
python manage.py migrate restapi zero
to undo the first migration, then retrypython manage.py migrate
. If the zero migration fails because the table doesn't actually exist, try it with--fake
. – AKX