简体   繁体   English

"为什么在使用 Heroku 部署 Django 时出现内部服务器错误(管理页面仍然有效)?"

[英]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."我正在尝试使用带有 Heroku 的 Django 部署我的 Django 网站,但它一直向我显示“内部服务器错误”。 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.在 SO 上关于这个问题的其他答案都没有解决我的问题,我注意到只有当我将 DEBUG 设置为 False 时我才会遇到这个问题。

My heroku logs commands show me the following error:我的 heroku 日志命令显示以下错误:

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' %} . 我认为这里的错误只是前导斜线,因此如果您只使用{% static 'images/posting/bike.png' %} ,它可能会起作用。

when you deploy to heroku successfully but Application error or internal server error当您成功部署到 heroku 但应用程序错误或内部服务器错误时

do the following !请执行下列操作 !

1 with debug=False every thing works fine in development environment 1 与 debug=False 一切都在开发环境中正常工作

2 make sure you did not import unnecessary packages . 2 确保你没有导入不必要的包。 3 check your code very carefully 4 run python manage.py collectstatic 3 非常仔细地检查你的代码 4 运行 python manage.py collectstatic
5 after deployed on heroku make sure to run heroku run python manage.py migrate 5 在heroku上部署后确保运行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 6 如果您成功部署并且它不起作用。问题肯定是代码中的小错误 在开发服务器上使用 debug=False 检查它们,并确保每件事情在开发服务器中也可以使用 debug=False 确保运行
python manage.py collectstatic 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. Heroku不会存储您的静态文件。 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) 在s3上存储文件不是免费的,但是却非常便宜(前50 TB /月$ 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/ 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 /

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我收到内部服务器错误 - Why am I getting an Internal Server error 使用部署到Heroku的Django应用程序时出现内部服务器错误。 该应用程序在本地工作 - I have an internal server error when using Django app deployed to Heroku. The app works locally 我正在 Heroku 上部署 Django App,部署成功后,出现操作错误 - I am deploying Django App on heroku, after successful deployment , I am getting operational Error 将 Django 应用程序部署到 Heroku 时出错 - Getting an error when deploying a Django app to Heroku 在 Heroku 上部署项目后出现内部服务器错误 - Getting internal server error after deploying the project on Heroku 为什么我会收到 500 内部服务器错误消息? - Why am I getting the 500 Internal Server Error message? BeautifulSoup:为什么会出现内部服务器错误? - BeautifulSoup: Why am i getting an internal server error? 为什么通过python请求调用rest api时出现500 Internal Server Error? - Why am I getting 500 Internal Server Error when calling post rest api via python request? 为什么在导入本地 python 文件时出现 500 内部服务器错误? - Why am I getting a 500 Internal Server Error when importing local python file? 在 Heroku 上部署后 Django 管理员访问错误 - Django admin access error after deploying on Heroku
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM