Django app works on localhost but not Heroku

Viewed 726

Right now I have a very basic app then simply displays some text. This works on both localhost and heroku. The problem is with the admin page. I am able to sign in to the admin page on localhost, but if I try to sign in on heroku, I get the following error:

ProgrammingError at /admin/login/
relation "auth_user" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...

The only difference between the script running on localhost and on heroku is that the one running on heroku uses django-heroku. I can't find any solution anywhere to this problem. Thanks in advance.

3 Answers

Run the following code

heroku run python manage.py migrate

This error ProgrammingError at /admin/login/ relation "auth_user" does not exist LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user... is caused due to problems in connectivity to Database or Migration error. Did you Migrate/Connect to the database properly ?

Ok, I figured out what I had to do. I ran the migration commands on my computer and incorrectly assumed that I wouldn't have to run them on Heroku as well. If anyone else has this problem, here's what you have to do:

  1. Go to https://heroku.com
  2. Select your website
  3. Near the top right corner, there will be a button labeled "more". Click that.
  4. Select "run console"
  5. Type python migrate.py migrate
  6. Type python migrate.py createsuperuser
Related