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
0 answers

set date format in Timezone aware date object

I want to get date in this format %d-%m-%Y" in following code: from django.utils.timezone import localtime, now from freezegun import freeze_time ..... @freeze_time("12-02-2012") def setUp(self): self.current_date =…
pyprism
  • 2,928
  • 10
  • 46
  • 85
1
vote
1 answer

Timezone issue after upgrading to Django 1.9

I have a test in Django 1.8.5, which passes. Here is is def test_user_returns_from_vacation_correctly_increments_review_timestamps(self): self.user.profile.on_vacation = True now = timezone.now() an_hour_ago = now -…
Tadgh
  • 1,999
  • 10
  • 23
1
vote
1 answer

Why timezone inside unittest in Django is different from timezone in view?

I'm using TestCase.client to test my views. And when I call timezone.now() from test case, i get 2015-11-17 07:48:26.826661+00:00, but when I call start = timezone.make_aware(datetime.strptime( date_text + ' ' + time, '%y/%m/%d…
Bunyk
  • 7,635
  • 8
  • 47
  • 79
1
vote
1 answer

Filter objects with a datetime range (00:00 to 23:59:99) in Django

I used django model filter with date. Origin data has time of Africa/Abidjan(UTC+00:00) and I save this data on my database. I set timezone about Asia/Seoul(UTC+09:00)and it's save well in my database. But I filter data with time_range=[2015-11-15,…
egaoneko
  • 389
  • 1
  • 5
  • 24
1
vote
1 answer

Django / DRF - Changing the timezone does not work

This is my settings.py: TIME_ZONE = 'America/Toronto' USE_I18N = True USE_L10N = True USE_TZ = True Before, it used to be TIME_ZONE = 'UTC' but I just changed it right now. I restarted the development server after changing it and created a post…
SilentDev
  • 20,997
  • 28
  • 111
  • 214
1
vote
3 answers

Django: DateTimeField received a naive datetime

I am working on creating a view that will only display posts whose deadlines dates have not passed. accomplish this I've added the following my views.py file: current_posts = Posts.objects.filter(post_name=post, deadline__range=[date.today(),…
ng150716
  • 2,195
  • 5
  • 40
  • 61
1
vote
0 answers

Django: changing timezone

I have following code in my django shell : >>> import datetime >>> import pytz >>> p = pytz.timezone("Asia/Kolkata") >>> pt = p.localize(datetime.datetime(2012,3,3,1,30)) >>> pt.date() datetime.date(2012, 3, 3) >>> pt.tzinfo
chaitanya90
  • 697
  • 2
  • 8
  • 24
1
vote
0 answers

Django Timezone is not displayed correctly

In my Django application I set USE_TZ = True and TIME_ZONE = 'Europe/Berlin'. My dates and time are displayed like: Sept. 27, 2014, 3 pm. In my opinion, and according to the specified timezone, the date and time should be displayed something like…
Martin Grohmann
  • 437
  • 2
  • 17
1
vote
1 answer

Postgresql date_trunc called in custom function through Django's connection.cursor()

I created a custom Postgresql function that performs some calculations and determines the beginning of a month by using the date_trunc function. When developing the custom function, I checked it from within a database connection established with…
1
vote
1 answer

handle django time zone with char field or django-time-zone field?

I have been using django-time-zone for some time, but I am now experiencing a lot of problems with django 1.7 https://github.com/mfogel/django-timezone-field I get the feeling that since Django doesn't have official support for a time zone field…
Atma
  • 29,141
  • 56
  • 198
  • 299
1
vote
1 answer

why does timezone aware datetime have 2 times in django

I set a date to midnight like this: user_tz = timezone('America/Los_Angeles') day_start = user_tz.localize(entered_at.replace(hour=00, minute=00)) I print the date and it looks like so: start date: 2014-08-21 00:00:00-07:00 What is the -7:00 at…
Atma
  • 29,141
  • 56
  • 198
  • 299
1
vote
0 answers

Django defaultfilters.date not timezone aware

Im trying to create a definition for django admin list_display, but the date filter is not timezone aware. If I just have the updated_date field in list_display, the time is correct. def get_edited_by(self): return u"%s %s - %s" %…
Tomas Jacobsen
  • 2,368
  • 6
  • 37
  • 81
1
vote
0 answers

Django and viewing dates in templates in the correct timezone

I can't seem to be able to use the timezones in django. I have read this here but when i try to apply it it won't work. my model class Model(models.Model) name = models.CharField(max_length=30) date = models.DateTimeField() My view…
Apostolos
  • 7,763
  • 17
  • 80
  • 150
1
vote
1 answer

Django - Editing the settings Default Time Zone

I'm now going through the process of making a django application time zone aware. Initially, the TIME_ZONE setting was set to "America/Los_Angeles", but I've decided that it's probably more standard to make it "UTC". I discovered some unintended…
tzenderman
  • 2,523
  • 3
  • 21
  • 24
1
vote
2 answers

Correct timesettings in Django for Celery

Im wondering how to correctly use timesettings in django and celery. Here is what I have: TIME_ZONE = 'Europe/Oslo' CELERY_TIMEZONE = 'Europe/Oslo' CELERY_ENABLE_UTC = True USE_TZ = True TZINFO = 'UTC' But the timestamp on my Celery task is ahead…
Tomas Jacobsen
  • 2,368
  • 6
  • 37
  • 81