简体   繁体   English

Django内部服务器错误

[英]Django Internal Server Error

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? 是什么会导致Django在执行python manage.py runserver时无错误运行,但是在尝试通过网络访问它时引发内部服务器错误? 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. 我有另一个项目在第一个Django驱动的页面上表示祝贺,并且最初在该项目中使用相同的.wsgi文件获得了相同的结果。

It wasn't until I tried to install this script in massivecoupon project that I got Internal Server Error: 直到我尝试在masscoupon项目中安装此脚本后,我才收到内部服务器错误:

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. /的ViewDoesNotExist /无法导入masscoupon.engine.views。 Error was: No module named libs 错误是:没有名为libs的模块

Quick answer: check your apache/tomcat access.log and error.log 快速解答:检查您的apache / tomcat access.log和error.log

Next, the other (not really dup) question I quoted above may be a different situation, but I recommend looking into the same things: 接下来,我上面引用的另一个(不是真正的重复) 问题可能是不同的情况,但是我建议您研究一下相同的东西:

Your PYTHONPATH may not contain your project directory, or your DJANGO_SETTINGS_MODULE may not contain 'mysite.website', at least from apache's point of view. 至少从apache的角度来看,您的PYTHONPATH可能不包含您的项目目录,或者您的DJANGO_SETTINGS_MODULE可能不包含“ mysite.website”。 Whatever user apache runs as for your website needs to have that set up for it, like in its .profile . 无论您的网站运行的是哪种用户apache,都需要为其进行设置,例如在.profile Or if you're using mod_python , they need to be set up in the .htaccess or apache's httpd.conf . 或者,如果您使用的是mod_python ,则需要在.htaccess或apache的httpd.conf进行设置。 Or if you're using mod_wsgi , it needs to be in the wsgi setup file -- passenger_wsgi.py or the like -- whatever apache's module will be looking for. 或者,如果你使用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 检查apache运行您的django网站的方式是否可以访问需要访问的文件
  • 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=1 set 确保您设置了SITE_ID=1
  • make sure that you have a site record added into the database 确保您已将站点记录添加到数据库中

You can use in command line 您可以在命令行中使用


    [user]$ python manage.py check

Regards 问候

First off check the Apache error log. 首先,请检查Apache错误日志。 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错误日志中没有任何内容(由于它是代码或Django处理请求时的内部错误),请在Django网站设置文件中将DEBUG设置为True并重新启动Apache,以便在浏览器中显示错误的详细信息。

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

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