Add from __future__ import unicode_literals, issue #37
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.http import HttpResponseForbidden
|
||||
@@ -11,16 +13,16 @@ class PermissionDeniedMiddleware(object):
|
||||
if isinstance(exception, PermissionDenied):
|
||||
try:
|
||||
# Handle import error but allow any type error from view
|
||||
callback = getattr(import_module(settings.ROOT_URLCONF), u'handler403')
|
||||
callback = getattr(import_module(settings.ROOT_URLCONF), 'handler403')
|
||||
return callback(request, exception)
|
||||
except (ImportError, AttributeError):
|
||||
# Try to get a 403 template
|
||||
try:
|
||||
# First look for a user-defined template named "403.html"
|
||||
t = loader.get_template(u'403.html')
|
||||
t = loader.get_template('403.html')
|
||||
except TemplateDoesNotExist:
|
||||
# If a template doesn't exist in the projct, use the following hardcoded template
|
||||
t = Template(u'''{% load i18n %}
|
||||
t = Template('''{% load i18n %}
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
|
||||
Reference in New Issue
Block a user