Python Django 内部服务器错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3295343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 10:18:09  来源:igfitidea点击:

Django Internal Server Error

pythondjango

提问by itecode

I'm new at this and stuck. What would cause Django to run without error when I do python manage.py runserver but then throw Internal Server Error when I try to access it through the web? I have another project giving the Congratulations on your first Django-powered page, and I got the same result with the same .wsgi file initially with this project.

我是新手,并被卡住了。当我执行 python manage.py runserver 但当我尝试通过网络访问它时抛出内部服务器错误时,什么会导致 Django 运行而没有错误?我有另一个项目在你的第一个由 Django 驱动的页面上给予祝贺,并且我最初在这个项目中使用相同的 .wsgi 文件得到了相同的结果。

It wasn't until I tried to install this script in massivecoupon project that I got Internal Server Error:

直到我尝试在大规模优惠券项目中安装此脚本时,才出现内部服务器错误:

http://github.com/coulix/Massive-Coupon---Open-source-groupon-clone

http://github.com/coulix/Massive-Coupon---Open-source-groupon-clone

UPDATE:

更新:

I set Debug to True in settings.py and now I am getting the django error:

我在 settings.py 中将 Debug 设置为 True ,现在我收到了 django 错误:

ViewDoesNotExist at / Could not import massivecoupon.engine.views. Error was: No module named libs

ViewDoesNotExist 在 / 无法导入 masscoupon.engine.views。错误是:没有名为 libs 的模块

回答by eruciform

Quick answer: check your apache/tomcat access.log and error.log

快速回答:检查您的 apache/tomcat access.log 和 error.log

Next, the other (not really dup) questionI quoted above may be a different situation, but I recommend looking into the same things:

接下来,我上面引用的另一个(不是真正的重复)问题可能是不同的情况,但我建议调查相同的事情:

Your PYTHONPATHmay not contain your project directory, or your DJANGO_SETTINGS_MODULEmay not contain 'mysite.website', at least from apache's point of view. Whatever user apache runs as for your website needs to have that set up for it, like in its .profile. Or if you're using mod_python, they need to be set up in the .htaccessor apache's httpd.conf. Or if you're using mod_wsgi, it needs to be in the wsgi setup file -- passenger_wsgi.pyor the like -- whatever apache's module will be looking for.

PYTHONPATH可能不包含您的项目目录,或者您DJANGO_SETTINGS_MODULE可能不包含“mysite.website”,至少从 apache 的角度来看。无论用户 apache 为您的网站运行什么,都需要为它进行设置,就像在它的.profile. 或者,如果您使用的是mod_python,则需要在.htaccess或 apache 的httpd.conf. 或者,如果您正在使用mod_wsgi,它需要在 wsgi 安装文件中——passenger_wsgi.py或者类似的——无论 apache 的模块要寻找什么。

Next:

下一个:

  • check if the files it needs to access are accessible by what apache runs your django site as
  • make sure your database is accessible by that user
  • and that the database setup/password is accessible by that user
  • make sure you have SITE_ID=1set
  • make sure that you have a site recordadded into the database
  • 检查它需要访问的文件是否可以通过apache 运行您的 django 站点的方式访问
  • 确保该用户可以访问您的数据库
  • 和数据库的建立/密码是访问用户
  • 确保你已经SITE_ID=1设置
  • 确保您已将站点记录添加到数据库中

回答by Graham Dumpleton

First off check the Apache error log. If there is nothing in Apache error log, due to it being an internal error to your code or Django while handling a request, set DEBUG to True in Django site settings file and restart Apache so details of error display in the browser.

首先检查Apache错误日志。如果 Apache 错误日志中没有任何内容,因为它是您的代码或 Django 在处理请求时的内部错误,请在 Django 站点设置文件中将 DEBUG 设置为 True 并重新启动 Apache,以便在浏览器中显示错误的详细信息。

回答by Javier Vazz

You can use in command line

您可以在命令行中使用


    [user]$ python manage.py check

Regards

问候