【问题标题】:Django + Apache + mod_wsgi fails when debug = false当 debug = false 时,Django + Apache + mod_wsgi 失败
【发布时间】:2012-06-14 16:27:22
【问题描述】:

我正在尝试部署一个正在开发的 django 应用程序。我已经更新它以使用 django 1.3,并且一切都在调试模式下工作。一旦我将设置中的 DEBUG 切换为 False,服务器就会返回以下故障。

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.2.14 (Ubuntu) Server at 192.168.1.220 Port 80

我个人不想使用 apache,但我坚持使用它。 谁能指出我可能是什么?

Traceback (most recent call last):

File "/home/fakeco/django1.3/django/core/handlers/base.py", line 89, in get_response
    response = middleware_method(request)

File "/home/fakeco/django1.3/django/middleware/common.py", line 67, in process_request
    if (not _is_valid_path(request.path_info, urlconf) and

File "/home/fakeco/django1.3/django/middleware/common.py", line 154, in _is_valid_path
    urlresolvers.resolve(path, urlconf)

File "/home/fakeco/django1.3/django/core/urlresolvers.py", line 342, in resolve
    return get_resolver(urlconf).resolve(path)

File "/home/fakeco/django1.3/django/core/urlresolvers.py", line 250, in resolve
    for pattern in self.url_patterns:

File "/home/fakeco/django1.3/django/core/urlresolvers.py", line 279, in _get_url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)

File "/home/fakeco/django1.3/django/core/urlresolvers.py", line 274, in _get_urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)

File "/home/fakeco/django1.3/django/utils/importlib.py", line 35, in import_module
    __import__(name)

File "/home/fakeco/domains/fakeco-directory.co.uk/fakecodirectory/urls.py", line 3, in <module>
    admin.autodiscover()

File "/home/fakeco/django1.3/django/contrib/admin/__init__.py", line 26, in autodiscover
    import_module('%s.admin' % app)

File "/home/fakeco/django1.3/django/utils/importlib.py", line 35, in import_module
    __import__(name)

File "/home/fakeco/domains/fakeco-directory.co.uk/fakecodirectory/contacts/admin.py", line 2, in <module>
    import fakecodirectory.contacts.models as models

File "/home/fakeco/domains/fakeco-directory.co.uk/fakecodirectory/contacts/models.py", line 3, in <module>
    from fakecodirectory.generic.models import Country, Title

File "/home/fakeco/domains/fakeco-directory.co.uk/fakecodirectory/generic/models.py", line 9, in <module>
    from fakecodirectory.contacts.models import Manufacturer

ImportError: cannot import name Manufacturer

【问题讨论】:

    标签: django apache mod-wsgi


    【解决方案1】:

    确保你有:

    1. 创建了500.html template
    2. 已将您的电子邮件地址添加到 ADMINS 设置,以便通过电子邮件向您发送回溯。
    3. 查看 apache 错误日志,看看那里是否有任何有用的信息。对于 Ubuntu,请查看 /var/log/apache2/

    【讨论】:

    • 我已经制作了 500.html 模板,但是感谢您提供有关电子邮件设置的提示,但不确定我如何测试该框是否可以发送电子邮件
    • 我现在有错误:ImportError: cannot import name Manufacturer
    • 它看起来像一个循环导入。您的 generic 应用程序正在从 contacts 应用程序导入,反之亦然。如果您正在导入以创建外键,则将模型作为字符串引用并删除导入。请参阅foreign key docs 了解更多信息。
    猜你喜欢
    • 2018-05-29
    • 2013-12-03
    • 2013-03-25
    • 2014-10-06
    • 2021-08-13
    • 2011-05-25
    • 1970-01-01
    • 2021-11-05
    • 1970-01-01
    相关资源
    最近更新 更多