Questions tagged [django-timezone]

Timezone handling specific questions with Django

Saving, displaying time is complicated when there are multiple timezones involved. In version 1.4 django web-framework has provided a way to handle them better.

This tag helps to consolidate questions related to use of Django timezone handling.

Here is detail documentation : Time zones

179 questions
2
votes
2 answers

Django. How to correctly save time & timezones

I have this code that behaves in a rather strange way and opens the question, how should I deal with timezones? So, first I have a datetime object I build from the info a user posts: time_zone = request.POST.get("time_zone") date_start =…
Alejandro Veintimilla
  • 10,743
  • 23
  • 91
  • 180
2
votes
0 answers

Setting timezone on a DateTime Field based on the location selected - Django ModelForm UpdateView

I have a model related to real world events that contains both DateTimeField and Location(PointField). The DateTime will always be entered/updated by the user in the TZ of the location (I'll refer to it as local time). Therefore, once the form is…
2
votes
1 answer

Is there a way for Django to accept naive datetimes with USE_TZ=True, or to suppress warnings?

Our company has been a long-time user of Django -- for more than 10 years. We are currently running Django 1.11.26. We've dealt with a lot of datetime-related issues over the years, but our current issue is proving challenging. Our goal is to do the…
2
votes
1 answer

How to get the next day's date in django.utils.timezone

I want to set the status of a task as due today, due tomorrow, overdue or upcoming if the date that the task is due on is today, yesterday (or before that) or tomorrow (or after tomorrow) This is what I do to compare today : if…
Amartya Gaur
  • 665
  • 6
  • 21
2
votes
2 answers

Problem with datetime.time() comparison in a pre_save signal

I have those models: class Interval(models.Model): from_time = models.TimeField(auto_now_add=False) to_time = models.TimeField(auto_now_add=False) class CheckIn(models.Model): date_time = models.DateTimeField(auto_now_add=True) …
2
votes
1 answer

Compare and Difference between datetime.now() and datetimefield from db

I can't find any answer to this that works for me. I'm trying to check difference between datetime for created post with datetime.now() example of what I would like to do in view.py if (datetime.now() - post.created_at).minutes > 10: …
sumpen
  • 503
  • 6
  • 19
2
votes
1 answer

Django timezone fields don't accept all pytz timezones

Django timezone fields are built upon pytz timezones, but some of the timezones of the latter are not valid for the fields. With a model like from django.db import models from timezone_field import TimeZoneField class TestModel(models.Model): …
jorgen
  • 3,425
  • 4
  • 31
  • 53
2
votes
1 answer

Django not storing the exact UTC time in db

I have a Django API/PostgreSql project, where i try to store the datetime in UTC format, which later i will convert to a correct timezone in the front end with angular. My current settings are: USE_TZ = True TIME_ZONE = 'US/Eastern' I was first…
user3334406
  • 337
  • 4
  • 16
2
votes
2 answers

Convert to Localtime django queryset

I have this following model definition in my models.py from django.db import models class Blog(models.Model): title = models.CharField(max_length=100) body = models.TextField() created = models.DateTimeField(auto_now_add=True) …
2
votes
2 answers

Django: Store gmt time in database table instead of local time

In my customer model I have two datetime fields for storing created and updated time. datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) When I create a customer, Now it is storing the…
Arun SS
  • 1,791
  • 8
  • 29
  • 48
2
votes
1 answer

Django datetime field not updating using time zone

setings.py:- USE_TZ = True TIME_ZONE = 'America/Chicago' class MyModel(models.Model): created_at = models.DateTimeField(auto_now_add=True) # time zone related field user_time_zone = models.CharField(max_length=255,…
Sohaib Ahmed
  • 207
  • 1
  • 3
  • 8
2
votes
1 answer

DST timezone issue in django app

I am making an events app in django. In that I need to make a copy of one event object (row/entry in DB) into another. It creates another object with same details. This event object involves timezone and Day light Saving. I am facing problems during…
RMK
  • 1,111
  • 4
  • 14
  • 33
2
votes
0 answers

django and timezone per user displayed in templates

Here is what I am trying to do: I want datetimes to be stored in UTC in the database. I want them to be displayed in the US/Eastern timezone for the admin. Each user has a field for the timezone so I'd like to display the times for their timezone…
Michael
  • 8,357
  • 20
  • 58
  • 86
2
votes
1 answer

what is the right way in django timezone setting

I just followed instructions on django website https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-date-based/ and TodayArchiveView was showing the date for the next day. my setting TIME_ZONE = 'UTC' and I changed it to TIME_ZONE =…
user2387135
  • 99
  • 1
  • 11
2
votes
1 answer

django time zone is not working ( return wrong time )

Django time zone support is wrong (but, I'm sure there is some thing I miss) I SET time to America/Los_Angeles with SERVER(UBUNTU), mysql, and django too. And the server is Oregon and I am in CA. As I know, there is no time difference. I printed…
joseph
  • 181
  • 1
  • 2
  • 11