change language programmatically

37 views
Skip to first unread message

lydy...@gmail.com

unread,
Jun 27, 2015, 2:51:55 PM6/27/15
to django-mode...@googlegroups.com
I got this code:

from django.utils.translation import activate

activate("nl")
print MyObject.objects.filter(title__isnull=False).query.sql_with_params()

activate("fr")
print MyObject.objects.filter(title__isnull=False).query.sql_with_params()

As default fallback language is nl, then both queries ar translated to -> "title_nl is not null", bet in second case I want -> "title_fr is not null"

How can i programmatically change language?

p.s. there could be great  idea, to implement something like MyObject.objects.language("fr")...
Reply all
Reply to author
Forward
0 new messages