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

  • Home
  • SEARCH
  • 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 8571057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:41:57+00:00 2026-06-11T18:41:57+00:00

Here are my two relevant settings in settings.py for my django project. USE_TZ =

  • 0

Here are my two relevant settings in settings.py for my django project.

USE_TZ = True
TIME_ZONE = 'Europe/Stockholm'

I have a DateTimeField defined like this in models.

triggeredTime = models.DateTimeField('Utlöses')

This is managed by the Django admin app and a form. So the form allows me to enter a date and time into this field of the database. The DB in this case is sqlite3.

(I wasn’t allowed to post an image as spam prevention so here it is as a link)
https://i.stack.imgur.com/9g1Ts.png

For the sake of the example the time I enter is 14:10:05.

Then I start the django shell.

$ python manage.py shell
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from scheduler.models import Task, Schedule
>>> s = Schedule.objects.all()
>>> for row in s:
...  print row.triggeredTime
... 
2012-09-11 12:10:05

This is clearly in UTC. Even if I try to add pytz to the mix and set tzinfo I get a value that is not in DST. I should not have to hard code DST into my code.

>>> import pytz
>>> from pytz import timezone
>>> stockholm = timezone('Europe/Stockholm')
>>> for row in s:
...  print row.triggeredTime.replace(tzinfo=stockholm)
... 
2012-09-11 12:10:05+01:00

For that matter, I shouldn’t even have to hard code the timezone since django claims to have that covered. So can someone please explain how to use timezones in Django?

FYI the server is physically located in the CET timezone so Europe/Stockholm is its current system wide setting.

  • 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-11T18:41:59+00:00Added an answer on June 11, 2026 at 6:41 pm

    SQLite doesn’t store TZ information, so you either have to convert dates to UTC when save into DB, set USE_TZ to False or change to Postgre

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

Sidebar

Related Questions

I have two seperate tables in my DB, here the relevant fields: table images:
Coding Platform ASP.NET 4.0 WebForms I have two pages that are relevant here Login.aspx
I have a question, here are two classes below: class Base{ public: virtual void
I have a very strange behavior with Request.Form . Here are two IIS 7
I have a menu bar that is rotated slightly. Here are two buttons as
Here's the relevant HTML: <div id=navcontainer> <ul id=navlist> <li><a href=#tab1>Item one</a></li> <li><a href=#tab2>Item two</a></li>
I have dropdown lists in two forms in a single .jsp. I would like
I have two simple tables as described here... Table = Person PersonID (int, PrimaryKey)
so here is the problem i have, i created two NSTimer objects and they
Okay, here is my problem: I have a form that requires to have two

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.