Django in Heroku throws error column does not exist

I’m trying to deploy my django project to heroku, however, it’s not working particularly well.
When I try to make an account, everything works fine, and logging in is fine. Locally, everything works as intended. However, when I try to create a new model instance on heroku, it throws the following error:

ProgrammingError at /contracts/new/
column "completed" of relation "contracts_clientcontract" does not exist
LINE 1: INSERT INTO "contracts_clientcontract" ("UUID", "completed",...
                                                        ^

I tried the advice given at https://stackoverflow.com/questions/42613536/django-programming-error-column-does-not-exist-even-after-running-migrations but it didn’t work. So I tried removing migration history, and that didn’t work. So I made a version of the project that had no migrations at all and sent that to heroku, and then ran both makemigrations and migrate using heroku run bash, and I still get the same error. I’m not sure what’s going on here…

Is it possible that because heroku uses postgres that I need to change the project’s settings to reflect that since it’s using sqlite3?

Can anyone point me in the right direction?

This is my databases setting for heroku:

DATABASES = {
    "default": dj_database_url.config(conn_max_age=600, default="sqlite:///" + os.path.join(BASE_DIR, "db.sqlite3"))
}

Can you share your DATABASES configuration? Are you saying that you’re using SQLite as your db?

If so, I think that’s not going to work on Heroku. SQLite saves a file locally, but Heroku can move your application to a different dyno at any time. That means that any files that are created on a Heroku dyno aren’t guaranteed to be there in the future. That would wreak havoc on a SQLite database since it could “disappear” at any time.

If you’re running on Heroku, I believe you’ll need to be able to connect to a different database like Postgres.

I can at least answer this part – django is db agnostic so you can use sqlite3 for development and push everything up to heroku and use postgres. I have the same setup and its working well.

I wound up using postgres so data isn’t lost during updates and whatnot, thank you though! <3

1 Like