简体   繁体   中英

Why am I getting an internal server error when deploying Django with Heroku (admin page still works)?

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.

raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
ValueError: Missing staticfiles manifest entry for '/images/posting/bike.png'

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' %} .

when you deploy to heroku successfully but Application error or internal server error

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


python manage.py collectstatic

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM