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 7488819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:02:53+00:00 2026-05-29T15:02:53+00:00

I have an Event model that includes a start time field, which is stored

  • 0

I have an Event model that includes a “start time” field, which is stored in UTC and mapped to the DB. The model also has a start_local() helper function the returns the event start as a Datetime object in the user’s local time. This happens via the Event instance’s reference to User, then get_profile() which has the timezone information.

This works, but the issue is that when I display long lists of events, there are 2 DB queries per row due to the user and profile lookups. This is silly because the timezone isn’t variable between rows, but the model doesn’t know that. My current setup passes the timezone information to start_local(), and that fixes the speed problem but is not a very pleasant from a design perspective. The Event instance knows how to get the user’s timezone, and having to rely on the calling function for help to avoid a big performance his is annoying.

Does anyone have an improvement to passing timezone information into the helper function?

  • 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-05-29T15:02:59+00:00Added an answer on May 29, 2026 at 3:02 pm

    Use select_related. I forget when OneToOne select related was introduced, but it works on 1.3.

    https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.select_related

    User.objects.select_related('userprofile') 
    # assuming the profile is called userprofile
    Event.objects.select_related('user', 'user__profile')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does jquery/javascript have any event model that you can attach to your objects? Basically
I have a model of events that has various information such as date, location,
I have a Core Data model in which a Task entity includes an optional
I have built a component library that includes an executive class which does work
Imagine I have a abstract FriendEvent model which has several different concrete implementations, ie.
I have a model that has ratings in it for an post. I want
I have two models: class Actor(models.Model): name = models.CharField(max_length=30, unique = True) event =
I have event manager process that dispatches events to subscribers (e.g. http_session_created, http_sesssion_destroyed). If
Input rz value In the head I have: Event.observe(window, 'load', function() { $$(input).each(function(field){ Event.observe(field,
I have some event handler on a boundary class that manages a persistence mechanism

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.