Reputation: 85
I am trying to deploy my Django website with Django with Heroku, and it keeps showing me "Internal Server Error." None of the other answers regarding this same problem here at SO solved my problem, and I noticed that I only have this problem when I set DEBUG to False.
My heroku logs commands show me the following error:
raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
ValueError: Missing staticfiles manifest entry for '/images/posting/bike.png'
I have setup my settings the following way:
ALLOWED_HOSTS = ["stratagembetaapp.herokuapp.com"]
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = "/media/"
django_heroku.settings(locals())
Additionally, gunicorn, django-heroku, and whitenoise are perfectly installed. My requirements.txt and Procfile are also in order.
I have also already run the "python manage.py collectstatic" in the Heroku shell, but I still get the same result.
Upvotes: 0
Views: 512
Reputation: 11
when you deploy to heroku successfully but Application error or internal server error
do the following !
1 with debug=False every thing works fine in development environment
2 make sure you did not import unnecessary packages .
3 check your code very carefully
4 run python manage.py collectstatic
5 after deployed on heroku make sure to run
heroku run python manage.py migrate
6 if you deployed successfully and it does not work .the problems are definitely minor errors in your code check them on dev server with debug=False and make sure every thing worksalso in dev server with debug=False make sure to run
python manage.py collectstatic
Upvotes: 1
Reputation: 3292
The error is that you are referencing a static file in your templates which doesn't exist (or isn't in the right place). In DEBUG mode this doesn't generate an error, but in production it does.
Somewhere in your templates you have a reference like this:
{% static '/images/posting/bike.png' %}
I think the error here is just that leading slash, so possibly it will work if you just use {% static 'images/posting/bike.png' %}
.
Upvotes: 1
Reputation: 116
Are you using a static file server? From your settings, it doesn't look like you are using one. Heroku won't store your static files. These tutorials can walk you through the process. Storing your files on s3 isn't free but it is super cheap (First 50 TB/ month $0.023 / GB)
https://www.codingforentrepreneurs.com/blog/s3-static-media-files-for-django/ https://simpleisbetterthancomplex.com/tutorial/2017/08/01/how-to-setup-amazon-s3-in-a-django-project.html https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/
Upvotes: 0