Dmitry Erokhin
Dmitry Erokhin

Reputation: 943

Using multilingual and localeurl in django

Using django-multilingual and localeurl.

Small sample of my main page view:

def main(request): #View for http://www.mysite.com/
    name = Dog.objects.all()[0].full_name #this is a translated field
    return render_to_response("home.html", {"name" : name})

Entering http://www.mysite.com/ redirects me to http://www.mysite.com/ru/ and "name" variable gets russian localization. For now it's ok...

But...

Entering http://www.mysite.com/en/ shows me same russian loclized variable.

During my experiments with debuger I've discovered:

The question is: should I change language of django-multilingual to request.LANGUAGE_CODE in each of my view myself, or it must be solved automaticly and I've done something wrong?

Upvotes: 1

Views: 933

Answers (2)

vixh
vixh

Reputation: 478

I have the same problem, after rotation with positions in MIDDLEWARE_CLASSES I've got the right order:

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware', 
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    #'django.middleware.locale.LocaleMiddleware',
    'localeurl.middleware.LocaleURLMiddleware',
    'multilingual.middleware.DefaultLanguageMiddleware',
    'multilingual.flatpages.middleware.FlatpageFallbackMiddleware',
    'django.middleware.common.CommonMiddleware', 
)

I comment #'django.middleware.locale.LocaleMiddleware' its doing the same as 'localeurl.middleware.LocaleURLMiddleware' I think.

Upvotes: 3

makkalot
makkalot

Reputation: 11

after removing django.middleware.locale.LocaleMiddleware it worked for me also ...

Upvotes: 1

Related Questions