You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing an API that needs to return a field localized for the request.
I'm using Django's LocaleMiddleware, which negotiates the HTTP Accept-language header against settings.LANGUAGE_CODES and sets the result as request.LANGUAGE_CODE. Is there a pattern or mixin I should be using on my ViewSets to activate that language for the response?
The text was updated successfully, but these errors were encountered:
Not that I'm aware of.. Django's LocaleMiddleware also calls translation.activate() so the current Django language will be set. django-parler uses django.utils.translation.get_language() by default when objects are fetched from the database.
You can set the language explicitly off course, using Model.objects.language(..)
I'm writing an API that needs to return a field localized for the request.
I'm using Django's
LocaleMiddleware
, which negotiates the HTTP Accept-language header againstsettings.LANGUAGE_CODES
and sets the result asrequest.LANGUAGE_CODE
. Is there a pattern or mixin I should be using on myViewSet
s to activate that language for the response?The text was updated successfully, but these errors were encountered: