0

this is my first time deploying a Django app to Heroku I followed the the Django Heroku documentation

the app is deployed successfully but when I open the app I got this error :

relation "products_category" does not exist
LINE 1: ...ory"."image", "products_category"."catogory" FROM "products_...

this is the changes I did to my settings.py after reading the documentation :

import django_heroku
django_heroku.settings(locals())

the database configuration is still running with sqlite3:

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
   }
  }

so what do I need to change in my setting to deploy my apps properly ?

1

2 Answers 2

1

first of all, in your dashboard, Heroku app go to settings and get rid of this DISABLE_COLLECTSTATIC conf.

in your settings.py add

STATIC_ROOT  = BASE_DIR / 'staticfiles'

create a directory called staticfiles, and add smth to it (eg. tmp.txt) just to make sure that git add . will include this directory. Push everything to Heroku and then use these commands:

heroku run python manage.py makemigrations

heroku run python manage.py migrate
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you I will try that and tell you if it works :)
TBH I'm not sure if it will work with your with your settings from heroku tutorial, but what I always do when I upload Django to heroku is follow this tutorial: codementor.io/@jamesezechukwu/… it is a little bit outdated (eg. stuff with whitenoise, read whitenoise.evans.io/en/stable/changelog.html#v4-0 and you will get through it) and additionally to it I will do this part from the answer
thanks I will create another app and use the tutorial to see if it works
0

try

heroku run python manage.py makemigrations

and then

heroku run python manage.py migrate

3 Comments

still the same error :django.db.utils.ProgrammingError: relation "products_category" does not exist LINE 1: ...ory"."image", "products_category"."catogory" FROM "products_...
when you deployed to Heroku, did you use this command: Heroku config:set DISABLE_COLLECTSTATIC=1
That's not good, I also had a hard time uploading my first project to Heroku. What I learned that you shouldn't disable collectstatic, instead try to follow my other answer(i will post it in a sec)

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.