NoReverseMatch exception if maintenance_mode.urls was not added to urlpatterns
andytzeng opened this issue · comments
Based on the readme, maintenance_mode.urls can be ignored if won't superusers are able to set maintenance_mode using urls. However, the exception throw as below:
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'maintenance_mode_off' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Exception Location: /usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py in _reverse_with_prefix, line 495
Check the middleware.py
url_off = reverse('maintenance_mode_off')
try:
resolve(url_off)
if url_off == request.path_info:
return None
except NoReverseMatch:
#maintenance_mode.urls not added
pass
the invoking revere
should be embraced in try-except block. Could you please double check the logic? Thanks.
Fixed and released 0.3.4 version on pypi.
Thanks for the report.
One thing I found: NoReverseMatch was not imported at line 3
Probably, add NoReverseMatch to line 3 as below:
from django.core.urlresolvers import resolve, reverse, NoReverseMatch
Thank you.
Sorry for the missing import, fixed and released 0.3.5 version on pypi.
Thanks again.