2

I'm developing a multilingual website using django 1.11 ,

'django.middleware.locale.LocaleMiddleware' middleware and

i18n_patterns

I use @login_required decorator for my views (for redirecting user to login page when he's not logged in) but it doesn't redirect user based on current language . for example when (not logged in) user goes to /fr/user/profile it will be redirected to /en/accounts/login?next=/fr/user/profile (but it should redirects to /fr/accounts/login?next=/fr/user/profile ) (because default website language is en(english) it always redirects to default language )

user1572461
  • 39
  • 1
  • 6

1 Answers1

0

Don't use hard-code settings, Django can handle url name like this:

LOGIN_URL = 'registration:login'

Checkout this: https://github.com/django/django/blob/stable/1.11.x/django/contrib/auth/views.py#L255

anhtran
  • 2,006
  • 4
  • 27
  • 53