django.urls.URLResolver - python examples

Here are the examples of the python api django.urls.URLResolver taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

3 View Complete Implementation : compat.py
Copyright Apache License 2.0
Author : BeanWei
def make_url_resolver(regex, urlpatterns):
    try:
        # Django 2.0
        from django.urls.resolvers import RegexPattern
        return URLResolver(RegexPattern(regex), urlpatterns)

    except ImportError:
        # Django < 2.0
        return URLResolver(regex, urlpatterns)

3 View Complete Implementation : urlresolvers.py
Copyright MIT License
Author : lorinkoz
def tenant_patterns(*urls):
    """
    Add the tenant prefix to every URL pattern within this function.
    This may only be used in the root URLconf, not in an included URLconf.
    """
    return [URLResolver(TenantPrefixPattern(), list(urls))]

3 View Complete Implementation : i18n.py
Copyright MIT License
Author : rizwansoaib
def i18n_patterns(*urls, prefix_default_language=True):
    """
    Add the language code prefix to every URL pattern within this function.
    This may only be used in the root URLconf, not in an included URLconf.
    """
    if not settings.USE_I18N:
        return list(urls)
    return [
        URLResolver(
            LocalePrefixPattern(prefix_default_language=prefix_default_language),
            list(urls),
        )
    ]

0 View Complete Implementation : compatibility.py
Copyright MIT License
Author : mwesterhof
    def get_resolver(url, url_config):
        return URLResolver(RegexPattern(r'^{}'.format(url)), url_config)