[Vuejs]-How add variable to django request from my front-end?

0πŸ‘

βœ…

I specified a language variable in my localStorage then I returned value to Content-Language header and after this I’ve could take the language value in my django request.

0πŸ‘

I see two approach :

  • Send the language value on every (interesting) request, as you proposed
  • Or, keep it in user settings in the backend : you add a charfield on a custom user model. When you need the language value during a request, you can access it through self.request.user.lang. You will have to add a route to update the value when users click on the icons.

It depends on how usual the language value is needed ; if its often, it will be simpler to have it in the backend. But you must keep the value up to date… Its a trade off πŸ™‚

Leave a comment