Quantcast
Viewing latest article 39
Browse Latest Browse All 44

When using i18n_patterns, how to reverse url without language code

I am using i18n_patterns but I want to use reverse to create a link to the page without language in the url (such that the user will be redirected based on cookies and headers and such).

I have tried

from django.utils.translation import activate, deactivate, get_languagecurrent_lang = get_language()deactivate()url = reverse(things)activate(current_lang)

That works for getting other language versions using activate(target_lang), but if I deactivate I just get urls for the default language (/en/account/ but I want /account/).

I already thought getting alternate language versions is overly complicated, but this I cannot manage at all. Any hints? (Without manually stripping LANGUAGE_CODE from the url)

UPDATE: I also tried

from django.core.urlresolvers import get_resolverget_resolver(None).reverse(*args, **kwargs)

but get NoReverseMatch


Viewing latest article 39
Browse Latest Browse All 44

Trending Articles