forked from CGM_Public/pretix_original
Handle Resolver404 exception in context processors
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.urlresolvers import get_script_prefix, resolve
|
from django.core.urlresolvers import Resolver404, get_script_prefix, resolve
|
||||||
|
|
||||||
from .signals import html_head, nav_event
|
from .signals import html_head, nav_event
|
||||||
|
|
||||||
@@ -8,7 +8,11 @@ def contextprocessor(request):
|
|||||||
"""
|
"""
|
||||||
Adds data to all template contexts
|
Adds data to all template contexts
|
||||||
"""
|
"""
|
||||||
url = resolve(request.path_info)
|
try:
|
||||||
|
url = resolve(request.path_info)
|
||||||
|
except Resolver404:
|
||||||
|
return {}
|
||||||
|
|
||||||
if not request.path.startswith(get_script_prefix() + 'control'):
|
if not request.path.startswith(get_script_prefix() + 'control'):
|
||||||
return {}
|
return {}
|
||||||
ctx = {
|
ctx = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from django.core.urlresolvers import resolve
|
from django.core.urlresolvers import Resolver404, resolve
|
||||||
|
|
||||||
from .signals import html_head
|
from .signals import html_head
|
||||||
|
|
||||||
@@ -7,7 +7,10 @@ def contextprocessor(request):
|
|||||||
"""
|
"""
|
||||||
Adds data to all template contexts
|
Adds data to all template contexts
|
||||||
"""
|
"""
|
||||||
url = resolve(request.path_info)
|
try:
|
||||||
|
url = resolve(request.path_info)
|
||||||
|
except Resolver404:
|
||||||
|
return {}
|
||||||
if url.namespace != 'presale':
|
if url.namespace != 'presale':
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user