middleware.py 402 Bytes
Newer Older
1
from django.conf import settings
root's avatar
use pip  
root committed
2
from django.core.urlresolvers import RegexURLResolver
3 4 5 6 7 8 9 10 11 12 13


def resolver(request):
    """
    Returns a RegexURLResolver for the request's urlconf.

    If the request does not have a urlconf object, then the default of
    settings.ROOT_URLCONF is used.
    """
    urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
    return RegexURLResolver(r'^/', urlconf)