我在这里检查了其他类似标题/问题的问题,但这些问题似乎都不适用于此。
我在虚拟机中有一个项目,项目运行良好,所有功能和网址都有效。
当我将settings.py
的值DEBUG
从True
更改为False
并重新启动apache时,我开始接收500 Internal Server Error
并在检查apache时log我看到这个错误:
[error] ImproperlyConfigured: The included urlconf None doesn't have any patterns in it
但我在urls/__init__.py
中有30个网址(如果需要,我可以显示完整的错误跟踪)
有人可以帮助我吗?
完整错误跟踪:
mod_wsgi (pid=27507): Exception occurred processing WSGI script '/vagrant/products_gallery/apache/django.wsgi'.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 218, in handle_uncaught_exception
return callback(request, **param_dict)
File "/vagrant/products_gallery/views.py", line 2844, in vhandler404
context_instance=RequestContext(request))
File "/usr/local/lib/python2.7/dist-packages/django/shortcuts/__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 188, in render_to_string
return t.render(context_instance)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 123, in render
return self._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 117, in _render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 757, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 127, in render
return compiled_parent._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 117, in _render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 757, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 159, in render
return self.render_template(self.template, context)
File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py", line 141, in render_template
output = template.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 123, in render
return self._render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 117, in _render
return self.nodelist.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 757, in render_node
return node.render(context)
File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 437, in render
url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 391, in reverse
*args, **kwargs)))
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 312, in reverse
possibilities = self.reverse_dict.getlist(lookup_view)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 229, in _get_reverse_dict
self._populate()
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 208, in _populate
for name in pattern.reverse_dict:
File "/usr/local/lib/python2.7/dist-packages/transurlvania/urlresolvers.py", line 214, in get_reverse_dict
self._lang_reverse_dicts[lang] = self._build_reverse_dict_for_lang(lang)
File "/usr/local/lib/python2.7/dist-packages/transurlvania/urlresolvers.py", line 171, in _build_reverse_dict_for_lang
for pattern in reversed(self.url_patterns):
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 283, in _get_url_patterns
raise ImproperlyConfigured("The included urlconf %s doesn't have any patterns in it" % self.urlconf_name)
ImproperlyConfigured: The included urlconf None doesn't have any patterns in it
Zlib: Compressed 624 to 385 : URL /
通常Django会返回失败的应用名称,在这种情况下,失败的应用是 Adyengo 。问题是在包文件中, /usr/local/lib/python2.7/dist-packages/adyengo/sites.py :
@property
def urls(self):
if not settings.DEBUG:
return
由于"空" return
,django错误为... The included urlconf **None** doesn't...
我评论/删除了行if not settings.DEBUG: return
,然后一切按预期工作
答案 0 :(得分:1)
检查模式是否包含指向不存在urlpatterns成员的不存在的模块或模块的include语句。
答案 1 :(得分:0)
你使用这样的东西(关于媒体文件):
if settings.DEBUG:
urlpatterns = patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
url(r'', include('django.contrib.staticfiles.urls')),
不要忘记向现有网址添加媒体网址,例如:
urlpatterns = patterns('',
/* some urls */
)
urlpatterns = +patterns('',
/* media urls */
)