- Rather than taking a regex argument, we just override the ``regex``
- function to always return the active language-code as regex.
- """
- @property
- def regex(self):
- language_code = get_language()
- if language_code == settings.LANGUAGE_CODE:
- return re.compile('')
- if language_code not in self._regex_dict:
- regex_compiled = re.compile('^%s/' % language_code, re.UNICODE)
- self._regex_dict[language_code] = regex_compiled
- return self._regex_dict[language_code]
+ class MyLocaleRegexURLResolver(LocaleRegexURLResolver):
+ """
+ A URL resolver that always matches the active language code as URL prefix.