Rafael Ortega
Rafael Ortega

Reputation: 454

Django 2.0 Internationalization | i18n_patterns not working

I have been working with i18n so that the URL included the prefix "/en/" or "/es/" depending on the users preferred language.

So far it was working fine while using Django 1.9 it even placed automatically the prefix even when the user didn't submit it in the URL (i.e. mySite.com would redirect to mySite.com/en/).

Now that I upgraded to 2.0 it is not working and it shows a 404 error:

Using the URLconf defined in smce.urls, Django tried these URL patterns, in this order:

en/

^static/(?P.*)$

^images/(?P.*)$

The empty path didn't match any of these.

At my root urls.py i have:

urlpatterns = i18n_patterns(
    path('admin/', admin.site.urls),

    path('login/', anonymous_required(views.login), {'template_name': 'login.html', 'authentication_form': LoginForm}, name='login'),

    path('', include('matrix.urls'), name='matrix'),
)

Any help or guidance would be appreciated.

Upvotes: 2

Views: 2308

Answers (1)

Mohammad Efazati
Mohammad Efazati

Reputation: 4920

For solving this problem just set these configs in settings.py

  LANGUAGE_CODE='en'
  prefix_default_language=False

Upvotes: 0

Related Questions