生产中admin.autodiscover出错

时间:2015-07-07 09:04:49

标签: python django django-urls production autodiscovery

尝试进入生产django项目。在开发过程中一切运行良好。在制作中,我有500个错误

这是Stack trace:

File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 164, in _add_installed_apps_translations
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 116, in __init__
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 206, in translation
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 304, in do_translate
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 327, in ugettext
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 84, in ugettext
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/functional.py", line 141, in __text_cast
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/encoding.py", line 92, in force_text
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 37, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 270, in r
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 37, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 345, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/defaultfilters.py", line 774, in date
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 674, in resolve
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/debug.py", line 89, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/debug.py", line 79, in render_node
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 903, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 201, in _render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 209, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/views/debug.py", line 384, in get_traceback_html
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/views/debug.py", line 97, in technical_500_response
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 261, in handle_uncaught_exception
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_response
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/module_loading.py", line 67, in autodiscover_modules
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
File "/home/megatexp/megatex_new/djangosites/megatex_new/megatex_new/urls.py", line 25, in <module>
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in urlconf_module
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 402, in url_patterns
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 366, in resolve
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 119, in get_response

全球urls.py文件:

from django.conf.urls import include, url
from django.contrib import admin
from articles.views import ArticleView
from shop.views import HomeView
from feedback.views import *
from django.conf import settings
from django.conf.urls.static import static

admin.autodiscover()

urlpatterns = [
    url(r'^ckeditor/', include('ckeditor.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^shop/', include('shop.urls')),
    url(r'^about/$', ArticleView.as_view(slug="Про нас"), name='about'),
    url(r'^feedback/', include('feedback.urls')),
    url(r'^captcha/', include('captcha.urls')),
    url(r'^$', HomeView.as_view(), name='home'),
] 
设置中

DEBUG = True

此外,app还没有运行在域的根目录上。也许它会导致自动发现的一些问题。因此我也添加了FORCE_SCRIPT_NAME,但结果是相同的:500 internal server error

我试图从urls.py中删除admin.autodiscover(),但我仍然遇到500错误。 这是堆栈

File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 164, in _add_installed_apps_translations
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 116, in __init__
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 206, in translation
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 304, in do_translate
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 327, in ugettext
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 84, in ugettext
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/functional.py", line 141, in __text_cast
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/encoding.py", line 92, in force_text
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 37, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 270, in r
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 37, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 345, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/defaultfilters.py", line 774, in date
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 674, in resolve
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/debug.py", line 89, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/debug.py", line 79, in render_node
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 903, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 201, in _render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 209, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/views/debug.py", line 384, in get_traceback_html
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/views/debug.py", line 97, in technical_500_response
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 261, in handle_uncaught_exception
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_response
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 231, in is_installed
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 171, in check_dependencies
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 250, in get_urls
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 291, in urls
File "/home/megatexp/megatex_new/djangosites/megatex_new/megatex_new/urls.py", line 27, in <module>
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in urlconf_module
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 402, in url_patterns
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 366, in resolve
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 119, in get_response

无法解析admin.urls

看起来服务器上的配置错误,但我无法确定的确切问题是什么。我用mod_wsgi在本地apache上运行这个项目,一切正常。当我在生产服务器上测试它时,我遇到了这种情况。

0 个答案:

没有答案