Skip to content
Advertisement

Change Django theme based on logged in, profile, or toggle

I would like to allow the user to have the ability to change the theme based on the following factors:

  • Anonymous
    • Check localStorage and if empty use default else use localStorage
  • Authenticated
    • Check localStorage and if empty use user profile setting

I have it all working except for Authenticated users, I don’t know how to check localStorage.

JavaScript

Advertisement

Answer

Here is updated code

JavaScript

above code will add localstorage theme first if it exists else it will add authenticated user theme if user is authenticated

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement