I turned debug to False in my settings.py file (note that before I turned it to false, everything was workign perfectly) and when I ran git push heroku master
and went to my website, the home page was working but that wasn't the case for all of my pages: on some, I got an error saying Server Error (500)
Here is my settings.py
code :
DEBUG = False
ALLOWED_HOSTS = ["hacka-labs.herokuapp.com"]
What I have noticed is that the urls where I pass an id aren't working
Please help me if you know the answer
I had a similar problem and it's hard to figure out when DEBUG is set to False. When I reconfigured it back to
DEBUG = True
everything worked fine again. So the problem wasThe solution to the problem in your case may differ from mine. But you can find the problem by changing the logging method of your Django project, so you can see more info in the command line when running
heroku logs -t -a <heroku-app>
even inDEBUG = False
mode.Change your django logging settings in
settings.py
as follow:Then run
heroku logs -t -a <heroku-app>
and open the url where you previously got 500 Error you will find out the problem in logs. Hope this will help you.In case there are some static files missing just switch your static root in
settings.py
as followSTATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
. Runningheroku run python manage.py collectstatic -a <heroku-app>
creates staticfiles directory.