[Fixed]-Django Translations – how to do it efficiently?

1👍

you can detect the language with request.LANGUAGE_CODE in your views

def list(request):
    lang = request.LANGUAGE_CODE
    entry = Entry.objects.get(pk=1)
    description = getattr(entry, 'description_%s' % lang)
    return render(request, 'name.html', {'description': description})

you may consider to use modeltranslation for this use case

Leave a comment