1

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 by two hours. How can I fix it?

Using:
Django - 1.6b2
celery - 3.0.23
django-celery - 3.0.23

Tomas Jacobsen
  • 2,368
  • 6
  • 37
  • 81

2 Answers2

1

You can use TZ default environment variable. Django will automatically use it with calling: http://docs.python.org/2/library/time.html#time.tzset If your celery runs from django, it will work there too.

Also you could use something like:

os.environ['TZ'] = 'your timezone'

at the beginning of ( manage.py or wsgi.py ) in your local installation.

Rustem
  • 2,884
  • 1
  • 17
  • 32
0

I think you might be hitting a bug in django-celery that I am also running into. There were timezone related changes in the last few releases of django-celery and this bug first showed up for me when I updated from 3.0.19 to 3.0.23.

I asked about this on the #celery IRC chat and was told that the django admin based celery task view is not that great and I should be using something like Flower (https://github.com/mher/flower) to monitor my tasks.

I installed and ran Flower and it did not suffer from the same timestamp issues that the django-celery admin based view does.

Fraser Graham
  • 4,650
  • 4
  • 22
  • 42