def no_redirect(pattern, locale_prefix=True, re_flags=None):
"""
Return a url matcher that will stop the redirect middleware and force
Django to continue with regular URL matching. For use when you have a URL pattern
you want to serve, and a broad catch-all pattern you want to redirect.
:param pattern: regex URL patter that will definitely not redirect.
:param locale_prefix: prepend the locale matching pattern.
:param re_flags: a string of any of the characters: "iLmsux". Will modify the `pattern` regex
based on the documented meaning of the flags (see python re module docs).
:return:
"""
if locale_prefix:
pattern = pattern.lstrip('^/')
pattern = LOCALE_RE + pattern
if re_flags:
pattern = '(?{})'.format(re_flags) + pattern
def _view(request, *args, **kwargs):
return None
return url(pattern, _view)
评论列表
文章目录