1👍
✅
You can chain fallback language and get first.
from itertools import chain
def myTrans(content, language_name):
regs_lang = ( TranslationText
.objects
.filter(language__name=language_name, content = content)
.exclude(i18n_txt__region_name=None)
.values_list('content', flat=True) )
regs_en = ( TranslationText
.objects
.filter(language__name='en', content = content)
.exclude(i18n_txt__region_name=None)
.values_list('content', flat=True) )
return next( chain( regs_lang, regs_en ) )
Source:stackexchange.com