Set or change the default language dynamically according to the user - Django

Of course there is, that is the whole point of translations. You've confused yourself by thinking of the "default" language; something that they've chosen is not the default, by definition.

The Django docs explain how to set the active language for a user explicitly. You can set this on save exactly as you describe.

You probably also want to re-set this value on login, again by passing the value from the user's profile.


referencing to what stated in the question:

I want the user to have their own "default language" set for their account.

The translation of a Django app with the preferred language selected by a registered user can be done with the middleware django-user-language-middleware. This allows easy translation of your Django app by looking at the selected language in the user.language field (or what the question defines as "default language" of a user).

Usage:

  1. Add a language field to your user model:

    class User(auth_base.AbstractBaseUser, auth.PermissionsMixin):
        # ...
        language = models.CharField(max_length=10,
                                    choices=settings.LANGUAGES,
                                    default=settings.LANGUAGE_CODE)
    
  2. Install the middleware from pip:

    pip install django-user-language-middleware

  3. Add it to your middleware class list in settings to listen to requests:

    MIDDLEWARE = [  # Or MIDDLEWARE_CLASSES on Django < 1.10
        ...
        'user_language_middleware.UserLanguageMiddleware',
        ...
    ]
    

I hope this may help people landing on this question in the future.