Reputation: 195
I have updated a Django blog to use slug urls <slug:slug>/
instead of id <int:pk>/
. I also added a slugField to the Article model, and converted all hrefs to article.slug
. Ran migrations and everything worked fine locally. However, when I pushed to Heroku I got an error.
This is what happens when I attempt to save a new article.
ProgrammingError at /admin/articles/article/
column articles_article.slug does not exist
LINE 1: ...ticles_article"."id", "articles_article"."title", "articles_...
^
Request Method: GET
Request URL: https://***********.herokuapp.com/admin/articles/article/
Django Version: 2.1.4
Exception Type: ProgrammingError
Exception Value:
column articles_article.slug does not exist
LINE 1: ...ticles_article"."id", "articles_article"."title", "articles_...
^
I checked my Heroku Postgress database and I found that the new slug column hadn't been added even though I did migrations. I'm not exactly sure what to do next. I'm currently searching for ways to manually update the heroku postgress, but if there's a less invasive way to solve this problem I'm all ears.
Upvotes: 0
Views: 676
Reputation: 276
first verify that the migration was executed (heroku)
verify that the last migration of the article model is in the django_migrations table
In case you can't find it, make sure you have updated migrations (local)
python manage.py makemigrations
run the migration in db production (heroku)
heroku run python manage.py migrate
Upvotes: 2
Reputation: 39
Did you happen to make migrations first then migrate? It's noted backward in your comment above. Also, are you sure you applied the migrations to your production database? It requires a settings flag added to the migrate command to point to your production settings/db location.
Upvotes: 0