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
0
votes
1 answer

How to apply timezones to Django Model DateTimeFields

When a Django model contains a DateTimeField the date is always saved in UTC timezone. If you add a date that had a time zone the information is translated and will be retrieved differently. This happens even if the TIME_ZONE has been set in…
0
votes
1 answer

Django models datetime with timezone UTC+1 saved as UTC+0

In my django project i have a model where i store data (in my read_date field) with a DateTime field for storing date (with timezone): class Results(models.Model): id = models.AutoField(primary_key=True) device = models.ForeignKey(Device,…
Manuel Santi
  • 1,106
  • 17
  • 46
0
votes
1 answer

Using __range in datetime in Django

I bumped into some problem . I have this in models.py class Order(models.Model): customer = models.ForeignKey('Customer' , on_delete=models.SET_NULL , null= True , blank = True) date_ordered = models.DateTimeField(auto_now_add = True) …
0
votes
0 answers

The time in influxdb comes in utc what should i do for UTC+3?

I set the time as utc+3 (europe/istanbul) in the database. The data I get from the device looks correct in influxdb, but when I pull data from influxdb to html, it shows as UTC without the time set. I pull the queries like this. When I add the…
Doğukan CEBECİ
  • 300
  • 1
  • 3
  • 13
0
votes
1 answer

Django and Timezones - Use same time across timezones

Okay. I've read a bunch of other answers, but none of them seem to be doing what I need to do. I need some help with times and dates. So I have an app such that the dates and times need to be based on the user's local time, but not change when the…
lovefaithswing
  • 1,510
  • 1
  • 21
  • 37
0
votes
1 answer

How to use timezones in Django Forms

Timezones in Django... I am not sure why this is so difficult, but I am stumped. I have a form that is overwriting the UTC dateTime in the database with the localtime of the user. I can't seem to figure out what is causing this. my settings.py…
MattG
  • 1,682
  • 5
  • 25
  • 45
0
votes
1 answer

DRF datetime field serializer 'Invalid datetime for the timezone' twice a year

I'm importing data from csv to InfluxDB through a Django Rest Framework API endpoint. The relevant part of the viewset: if request.method == "PUT": measurements = InputMeasurementSerializer(data=request.data, many=True) …
0
votes
2 answers

How to show UTC time in local timezone in Django view?

I use UTC in my Django app and I want to display the time for my local timezone; 'Europe/Stockholm'. I just can't get this simple thing to work so I must be doing something wrong. I just can't figure out what it is... This is what I have in my…
0
votes
2 answers

Django strict checking for aware timestamps

In Django, if you have USE_TZ = True and pass a naive datetime to a database call, it logs the error: DateTimeField Model.field received a naive datetime (2021-01-01 00:00:00) while time zone support is active. However, Django goes ahead and does…
Zags
  • 37,389
  • 14
  • 105
  • 140
0
votes
0 answers

How to format time into readable format in Django

I have a send_sms function, but the date format from the message is too long and detailed. I want it to format from 2021-01-24 05:12:21.517854+00:00 into just (5:12PM, 24Jan2021) How can I do it? Thanks! def send_sms(request): z =…
Junely
  • 21
  • 6
0
votes
1 answer

convert timezone pytz string to offset in python/django

I am using django/python How do I convert pytz timezone string such as 'Asia/Kuala_Lumpur' to offset information ('+0800' or '80'). I am not able to find the exact function here:https://docs.djangoproject.com/en/3.1/topics/i18n/timezones/ I would…
Axil
  • 3,606
  • 10
  • 62
  • 136
0
votes
1 answer

Django displays tow different timezones for the same model attribute when viewing in admin site vs a query for the model in a script

How to make consistant timezone across Django. In my settings.py I have TIME_ZONE = 'America/New_York' and USE_TZ = True. I have a model def MyModel(models.Model): date_time = models.DateTimeField(auto_now_add=True) if I view a field from that…
juju
  • 884
  • 1
  • 9
  • 31
0
votes
2 answers

How to display a list of timezones for vendors to choose from when he lists an event and other visitors are able to see the time in their local time?

We have a web app(Django based backend and Node/ReactJs based front-end, MySQL based DB), and a Flutter based mobile app. We are creating a system where a vendor can create a meeting invite and list the time (and timezone) at which the meeting…
0
votes
0 answers

(Auto_now_add = True) result different between 2 fields

I have two models also including the datetimeField but the format and result is different. Did I miss somethings? models.py: class Order(models.Model): start_date = models.DateTimeField(auto_now_add=True) class Payment(models.Model): timestamp =…
Hugo Yu
  • 105
  • 9
0
votes
1 answer

UnknownTimeZoneError in Pandas.Timestamp.now

I want to append the Timestamp of current time for my timezone, but don't know where to find the correct value of my timezone. Apparently, it's Islamabad/Karachi, but no success. Here is my small code chunk import pandas as pd ... #df -> a…
DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98