1👍
I think is because of not existing idom in languages code, first check it :
from django.utils.translation import check_for_language
user_language = user.profile.idiom
if user_language and check_for_language(user_language ):
translation.activate(user_language)
else:
raise Exeption()
django.utils.translation.check_for_language() which checks if the given language is supported by Django.
read more
Source:stackexchange.com