1. wnielson
  2. django-chronograph
  3. Issues
Issue #31 new

ValueError: astimezone() cannot be applied to a naive datetime

Алексей Пахомов
created an issue

File "/home/nsd/lib/python2.6/site-packages/django/contrib/admin/templatetags/admin_list.py", line 184, in items_for_result f, attr, value = lookup_field(field_name, result, cl.model_admin)

File "/home/nsd/lib/python2.6/site-packages/django/contrib/admin/util.py", line 254, in lookup_field value = attr(obj)

File "/home/nsd/lib/python2.6/site-packages/chronograph/admin.py", line 82, in get_timeuntil next_run = dates.localtime(obj.next_run)

File "/home/nsd/lib/python2.6/site-packages/chronograph/compatibility/dates.py", line 62, in localtime return timezone.localtime(dt)

File "/home/nsd/lib/python2.6/site-packages/django/utils/timezone.py", line 237, in localtime value = value.astimezone(timezone)

ValueError: astimezone() cannot be applied to a naive datetime

============== Python 2.6.8 django 1.5.0

Comments (5)

  1. Leanne McAllister

    To make the datetime timezone-aware, I made the following change in chronograph/compatibility/dates.py:

    def localtime(dt):
        if timezone:
            return timezone.localtime(make_aware(dt, tz="current"))
        return dt
    

    I'm not sure yet if this is a complete/correct fix, but it's working for me so far. I can now create a job via the django admin panel, and the job's next run time appears to be correct.

    [Django 1.5, Python 2.7.2]

  2. Ying Kit Yuen

    This is fixed in the development branch even it is not merged. try to install the dev version

    pip install https://bitbucket.org/wnielson/django-chronograph/get/default.tar.gz
    
  3. Log in to comment