Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8308253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:45:04+00:00 2026-06-08T18:45:04+00:00

In django, I use the authenticate() function to log users in. Using request.user ,

  • 0

In django, I use the authenticate() function to log users in. Using request.user, I can access the logged in user’s information which is pulled from the users table. If I do request.user.id, I can get the user’s id. In any template, on any request, I can do user.username to get the username.

Is there a way by which I can add values to the request.user variable so that I can use them throughout my application and in templates?

For example, I would like to have this: request.user.timezone set when the user logs in to the site; I should be able to access this variable in templates and in my views.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:45:05+00:00Added an answer on June 8, 2026 at 6:45 pm

    Would you like to let the user change it time-zone and force a specific time-zone ? I assume you would, if so you would like to keep the timezone configurable in your database. Therfore I would suggest you to make a UserProfile model which has one to one relations with the User Object.

    You can do :

    class UserProfile(models.Model):
        user = models.OneToOneField(User)
        time_zone = models.whateverField()
        ... add anything else you would like to extend your profile ...
    

    On your templete you will be able to get the timezone by doing that :

    {{ request.user.userprofile.time_zone }}
    

    Simple and very clean.

    If you would like to have an automatic creation of your userprofile whenever you save a User object, you can use signals for that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I use Django's logout function to log out an authenticated user, it switched
I use django admin for my users to add their Model objects, as you
I'm using django comments frameworks . All the comments are posted by authenticated users.
I am using django-registration, and just set it up. {{user.is_authenticated }} is true, even
I noticed django use this to process the string, but can I get a
I'm trying to use a User model inheritance in my django application. Model looks
I am creating my application using Django, and am wondering how I can make
I am building my first django app that uses user authentication and I'm using
How can i use django-notifications or django-signals to make something like facebook updates notification
I have a meta class for the Django User model that I use to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.