AlvaroAV AlvaroAV - 1 month ago 10
Python Question

Django Error when change DEBUG to False

I've checked other questions here with similar title/issue but none of them seems to apply here.

I have a project in a virtual machine, and the project is running well with all features and urls working.

When I change in the

settings.py
the value of
DEBUG
from
True
to
False
and restart apache, I start receiving
500 Internal Server Error
and when I check apache log I see this error:

[error] ImproperlyConfigured: The included urlconf None doesn't have any patterns in it


but I have like 30 url's in
urls/__init__.py
(I can show full error trace if it's needed)

Does anyone can help me here ?

Full Error Trace:

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 /





Solved



Usually Django returns the name of the app that's failing, in this case the app that were failing was Adyengo. The issue was that in the package files, /usr/local/lib/python2.7/dist-packages/adyengo/sites.py:

@property
def urls(self):

if not settings.DEBUG:
return


Because of the "empty"
return
, the django error is
... The included urlconf **None** doesn't...


I commented/removed the lines
if not settings.DEBUG: return
and then everything works as expected

Answer

Check your patterns for include statements that point to non-existent modules or modules that do not have a urlpatterns member.

Comments