Ask Your Question

Getting 'can't subtract offset-naive and offset-aware datetimes'

asked 2013-04-03 23:49:41 -0600

yjkogan gravatar image

At a few places in the codebase, I'm getting the error that I can't subtract offset-naive and offset-aware datetimes. I tried fixing it in one place in the source, but ran into it somewhere else. Any advice?


Request Method: GET
Request URL:

Django Version: 1.4.1
Python Version: 2.7.3
Installed Applications:
Installed Middleware:

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/askbot/views/" in questions
  235.             'update_avatar_data': schedules.should_update_avatar_data(request),
File "/usr/local/lib/python2.7/dist-packages/askbot/" in should_update_avatar_data
  11.         if ( - user.last_login).days <= 1:

Exception Type: TypeError at /questions/
Exception Value: can't subtract offset-naive and offset-aware datetimes
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-04-04 01:31:16 -0600

yjkogan gravatar image

Answered my own question.

The default file created by (at least in django 1.5) sets USE_TZ to True.

Just set USE_TZ to False, or simply remove it from the settings file, since in the absence of a directive the value is assumed to be False.

edit flag offensive delete link more


We've not tested yet Askbot with django 1.5, in fact in the repository version, we've added an upper limit for the django version. Does askbot work for you in 1.5?

Evgeny gravatar imageEvgeny ( 2013-04-04 21:16:00 -0600 )edit

I think I ran into a different issue with 1.5 specific to installation and had to roll it back in order to get askbot working. However, I initialized the repo with 1.5 b/c they changed the directory format in 1.4 (i think) and I wanted my project to match the new format. Managed to get that working with medium-low pain level

yjkogan gravatar imageyjkogan ( 2013-04-05 02:00:43 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-04-03 23:49:41 -0600

Seen: 2,147 times

Last updated: Apr 04 '13