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
1
vote
1 answer

Django 1.5 Timezone.now()

I am newbie and trying to make my Unit Test pass but having problems with DateTimeField. In my settings, I have USE_TZ = True and TIME_ZONE set. Using MongoDb. First the test is giving me an error complaining about comparing offset-naive and…
yellowbuck
  • 1,071
  • 1
  • 15
  • 20
1
vote
1 answer

STD offset for pytz timezones

i want to add UTC offset to timezone list from tz database, like: * (UTC +0) Europe/London For list of timezones i use pytz.common_timezones, but cant retrieve STD utcoffset for timezone, because all methods on timezone object requires dt object,…
Nikita
  • 2,780
  • 3
  • 15
  • 12
1
vote
0 answers

How to handle user timezones preference with Django PostgreSQL?

I am new to Django timezones. I need my users to select their timezone from a list so I can store it in PostgreSQL database. My questions are: What is the best way to generate a list of timezones for the user to select from? What is the best data…
1
vote
1 answer

How to convert the time entered in django admin into utc?

There are a lot of questions here on SO to make Django-Admin time aware and all related stuff. But I couldn't get help from the existing ones. So I am asking a new one with a slightly different intent. I want that when a user enters some data via…
Indradhanush Gupta
  • 4,067
  • 10
  • 44
  • 60
1
vote
2 answers

django localtime

I'm trying to convert utc times to localtime in my template and for some reason doing: {% load tz %} {% localtime on %} {{ value }} {% endlocaltime %} still gives me the value in utc however {{ value|localtime }} gives me the value using my…
9-bits
  • 10,395
  • 21
  • 61
  • 83
0
votes
1 answer

Formatting timestamps on the frontend

As has been asked in many other questions, how can I make e.g. Django admin portal use my browser's current time zone? The usual way to solve that is to get the server to guess the time zone the client wants (potentially storing time zone…
OLEGSHA
  • 388
  • 3
  • 13
0
votes
1 answer

Django ignores timezone settings

I am trying to create a record in my Django project with the timezone set to Europe/Rome. When I create the model object, I use this function to set the timezone: MyModel.objects.create( name="trial", …
Gimbo
  • 13
  • 5
0
votes
1 answer

Is current time zone detected by default if `USE_TZ=True` in Django?

It is mentioned in docs that the current time zone should be activated. You should set the current time zone to the end user’s actual time zone with activate(). Otherwise, the default time zone is used However, I see that the values are parsed in…
Yasser Mohsen
  • 1,411
  • 1
  • 12
  • 29
0
votes
0 answers

Django - set timezone in a django-admin command

I have a django-admin command which is handling message sending to different users in different countries. Each user should get the message at the same date - according to their local timezone. For example: a user in Paris should get a message every…
0
votes
0 answers

ERROR type object 'TimeZoneField' has no attribute 'CHOICES'

I have a celery beat task that works fine in staging as well as local server. But I am getting an error as ERROR type object 'TimeZoneField' has no attribute 'CHOICES' in the production server. Can anyone help me with this? This is the package…
0
votes
0 answers

Django forms update instance while keep date/time unchanged

I've created a model for properties and connected it to a form. I started to render the form with template tags using {{ form.as_p }} and everything worked fine when I used my view for editing/updating an instance. But I wanted to customize my html…
Erra
  • 1
0
votes
0 answers

Django - Flexible DateTimeField precision with timezone

I have a database model that includes a DateTimeField as below: class Person(models.Model): .... date_of_birth = models.DateTimeField() date_of_birth_precision = models.CharField(max_length=3, choices=( ('D', 'Day'), …
Yasser Mohsen
  • 1,411
  • 1
  • 12
  • 29
0
votes
0 answers

django TimeField getting saved with wrong time zone

I have a simple Group model: class Group(models.Model): leader = models.ForeignKey(User, on_delete=models.CASCADE) name = models.CharField(max_length=55) description = models.TextField() joined = models.ManyToManyField(User, blank=True) …
0
votes
0 answers

Is timzone.now() cached when used in a checkconstraint?

I have a timezone aware model field with a CheckConstraint: class MyModel(models.Model): my_text = models.CharField() my_date = models.DateTimeField() class Meta: constraints = [ models.CheckConstraint( …
alias51
  • 8,178
  • 22
  • 94
  • 166
0
votes
0 answers

Django: Trying to add 'SHORT_TIME_FORMAT' somehow changes time zone to Chicargo

I required some extra date/time formats in addition to ones Django ships with, sI created these new formats: SHORT_TIME_FORMAT FILE_DATETIME_FORMAT ISO8601_DATETIME_FORMAT. So that I could use them in templates like this: {{…
run_the_race
  • 1,344
  • 2
  • 36
  • 62