0
votes

I deployed my app on Heroku, I can see it perfectly from the local server where the website works. The problem is that whenever I try to enter as the admin within the Heroku website (https://awayfromspain.herokuapp.com/admin/) I got the following error:

ProgrammingError at /admin/
relation "django_session" does not exist
LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...

I also get this when I try to enter in the pages that are related to my models:

column myapp_experience.slug does not exist
LINE 1: ...p_experience"."title", "myapp_experience"."text", "myapp_exp...

I think I have problems with the database... but I tried to flush and I get:

Running python manage.py flush on ⬢ awayfromspain... up, run.2445 (Free)
You have requested a flush of the database.
This will IRREVERSIBLY DESTROY all data currently in the 'df1neimk7ipkd5' database,
and return each table to an empty state.
Are you sure you want to do this?

    Type 'yes' to continue, or 'no' to cancel: yes
CommandError: Database df1neimk7ipkd5 couldn't be flushed. Possible reasons:
  * The database isn't running or isn't configured correctly.
  * At least one of the expected database tables doesn't exist.
  * The SQL was invalid.
Hint: Look at the output of 'django-admin sqlflush'. That's the SQL this command wasn't able to run.
The full error: cannot truncate a table referenced in a foreign key constraint
DETAIL:  Table "myapp_franceexperience" references "auth_user".
HINT:  Truncate table "myapp_franceexperience" at the same time, or use TRUNCATE ... CASCADE.

Where franceexperience was a model that I deleted. How should I proceed? I applied migrations.

Thanks in advance !

1

1 Answers

0
votes

Your migrations have obviously got out of sync; franceexperience should have been deleted when you removed the model.

You should makemigrations again locally and check that it adds a migration to delete that table. Then commit your code, push it, and do heroku run ./manage.py migrate; this should remove the deleted table but also hopefully add the missing session table.