django, change language settings dynamically

After some failed attempts, I just found how to change the language settings dynamically in django, and I thought it could be useful to someone. Just use function activate() from django.utils.translation. For example:

from django.utils.translation import activate

activate(‘es-ES’)

will change global language settings to ‘es-ES’ (Spain spanish). I use it because I have two forms and I want that errors appear in different languages, but I do not want to get into gettext

6 Responses to “django, change language settings dynamically”

  1. Yury Lifshits Says:

    Thanks a lot!
    You prob

  2. Yury Lifshits Says:

    Thanks a lot, Fabian!!

    You probably saved me a few hours!!!

  3. Candy Harris Says:

    Thanks for this blog. I am new at development and this got me straight.

  4. Larry Henrie Says:

    This is great! Thanks for this blog. I am starting python and this will help a lot.

  5. Laveta Belko Says:

    For the reason that a Newbie I am incessantly scouring the web on the web to get this type of information .Thank you:P

  6. Jared Says:

    Fabian,
    Is there a way to set other Django settings dynamically, specifically I am looking to change the email_host? Thanks

Leave a Reply