@contextlib.contextmanager
def no_translation(lang=None):
 old_lang = translation.trans_real.get_language()
 if lang:
  translation.activate(lang)
 else:
  translation.activate(settings.LANGUAGE_CODE)
 (yield)
 translation.activate(old_lang)

@ contextlib . contextmanager def no_translation ( lang = None ) : old_lang = translation . trans_real . get_language ( ) if lang : translation . activate ( lang ) else : translation . activate ( settings . LANGUAGE_CODE ) ( yield ) translation . activate ( old_lang )
activate the settings lang .