3

I am new to publishing django apps on heroku. I have read their tutorials and figured I would start simple by modifying their template django project.

So far everything was good.

Then I made an app as one does, made a model and ran

python3 manage.py makemigrations my_app
python3 manage.py migrate

and things seemed ok.

I then pushed to heroku and there were no immediate complaints.

However, now when I try to make save a new model I get the error:

ProgrammingError at /my_app/
relation "my_app_myappmodel" does not exist
LINE 1: INSERT INTO "my_app_myappmodel" ("field1", "field2", "field3") VALUES...

odd...

So I run this locally and everything works fine.

I have tried cleaning my migrations, faking my migrations, squashing my migrations, etc (as other S.O. posts suggest)

Nothing works.

What is up and how do I fix it?

4
  • how much migrations did you have, may be you can add code here? Commented Sep 13, 2017 at 13:54
  • @BearBrown it is literally just the initial Commented Sep 13, 2017 at 13:57
  • Have you run "migrate" on heroku instance? Commented Sep 13, 2017 at 13:58
  • @AamirAdnan how is that different than running migrate locally and pushing the git repo Commented Sep 13, 2017 at 13:59

2 Answers 2

4

You need to actually run the migrations on Heroku once you have pushed the code generated by makemigrations. You do this via heroku run manage.py migrate.

Sign up to request clarification or add additional context in comments.

Comments

2

run the following command from your terminal

heroku run python manage.py migrate

or you can also do:

in your local settings.py, change your DATABASES variable to use the heroku one then run from the terminal

python manage.py makemigrations
python manage.py migrate

but you should not normally locally make changes to the heroku production database (as in option 2) except if you are really desperate or don't care

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.