Language code prepended twice when using url-reverse template filter and i18n urls with localeurl

StackOverflow https://stackoverflow.com/questions/16944653

  •  31-05-2022
  •  | 
  •  

Question

Django 1.5, using the app

localeurl

With urlpattern like so :

urlpatterns += i18n_patterns(
    url(r'^user/login/?$','django.contrib.auth.views.login',\
          {'template_name':'user/login.html'}),
)

and in the template, this

{% url 'django.contrib.auth.views.login' %}

prepends the language code twice . It outputs "en/en/user/login" .

Does anybody have an idea how to get rid of the double language code, or where this might come from ?

Was it helpful?

Solution

The mistake was to add the same url-patterns with both

urlpatterns += patterns( ... ) and

urlpatterns += i18n_patterns( ... )

That caused said error. It works when the patterns are added only through i18n_patterns

Also, "localeurl" is not necessary (thanks @Jingo)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top