Skip to content
Advertisement

NameError: name ‘urlpatterns’ is not defined using i18n_patterns

I have problems writing the urls for translation. According to this question I understand that it is because I have += so I need to put this = the bad thing is that I have to translate all my urls I can’t leave any outside of i18n, what can I do to include all my urls there?

JavaScript

Advertisement

Answer

You did not define urlpatterns before. If you want to translate all paths, you use:

JavaScript

In the linked answer, it first defines a list, and then extends it with +=, exactly because not all url patterns are translated there. But if all patterns should be translated, you assign the result of i18n_patterns(..) to the urlpatterns.

Advertisement