astimezone() cannot be applied to a naive datetime #233

Closed
coderam opened this Issue Apr 16, 2013 · 6 comments

Comments

3 participants
@coderam

coderam commented Apr 16, 2013

I upgraded to the latest blog zinnia and to Django 1.5.1 from 1.4.x and receive the following error:

astimezone() cannot be applied to a naive datetime

Copy and pasted:

Environment:

Request Method: GET
Request URL: http://givity.coml:8000/blog/

Django Version: 1.5.1
Python Version: 2.7.4
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'tagging',
'mptt',
'zinnia',
'django_extensions',
'django.contrib.formtools',
'sorl.thumbnail',
'base',
'accounts')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'base.middleware.subdomain.SubdomainMiddleware')

Traceback:
File "C:\Users\coderam\Envs\givity\lib\site-packages\django\core\handlers\base.py" in get_response

  1.                     response = callback(request, _callback_args, *_callback_kwargs)
    
    File "C:\Users\coderam\Envs\givity\lib\site-packages\django\views\generic\base.py" in view
  2.         return self.dispatch(request, _args, *_kwargs)
    
    File "C:\Users\coderam\Envs\givity\lib\site-packages\django\views\generic\base.py" in dispatch
  3.     return handler(request, _args, *_kwargs)
    
    File "C:\Users\coderam\Envs\givity\lib\site-packages\django\views\generic\dates.py" in get
  4.     return self.render_to_response(context)
    
    File "C:\Users\coderam\Envs\givity\lib\site-packages\django\views\generic\base.py" in render_to_response
  5.         template = self.get_template_names(),
    
    File "C:\Users\coderam\Envs\givity\lib\site-packages\zinnia\views\mixins\templates.py" in get_template_names
  6.     year = self.get_archive_part_value('year')
    
    File "C:\Users\coderam\Envs\givity\lib\site-packages\zinnia\views\mixins\templates.py" in get_archive_part_value
  7.         self.today = timezone.localtime(timezone.now()).date()
    
    File "C:\Users\coderam\Envs\givity\lib\site-packages\django\utils\timezone.py" in localtime
  8. value = value.astimezone(timezone)
    

Exception Type: ValueError at /blog/
Exception Value: astimezone() cannot be applied to a naive datetime

@ksysctl

This comment has been minimized.

Show comment
Hide comment
@ksysctl

ksysctl Apr 17, 2013

I just installed zinnia and I received the same error after access to the /blog and when I try to add a new entry

env:
Python 2.6
Django 1.5.0
Zinnia 0.12.3

ksysctl commented Apr 17, 2013

I just installed zinnia and I received the same error after access to the /blog and when I try to add a new entry

env:
Python 2.6
Django 1.5.0
Zinnia 0.12.3

@ksysctl

This comment has been minimized.

Show comment
Hide comment
@ksysctl

ksysctl Apr 17, 2013

I was investigating how to fix that cloning zinnia, and I see django.utils.timezone.now() convert that object datetime but it depends if settings.USE_TZ is enabled so I did then I fixed that.

settings.py

USE_TZ = True

That fixed it!.

ksysctl commented Apr 17, 2013

I was investigating how to fix that cloning zinnia, and I see django.utils.timezone.now() convert that object datetime but it depends if settings.USE_TZ is enabled so I did then I fixed that.

settings.py

USE_TZ = True

That fixed it!.

@coderam

This comment has been minimized.

Show comment
Hide comment
@coderam

coderam Apr 17, 2013

Can you merge this into the core django-blog-zinnia repo -- that way I'll
be able to do a simple pip install --upgrade ?

On Wed, Apr 17, 2013 at 11:10 AM, Moises Brenes notifications@github.comwrote:

I was investigating how to fix that cloning zinnia, and I see
django.utils.timezone.now() convert that object datetime but it depends if
settings.USE_TZ is enabled so I did then I fixed that.
settings.py

USE_TZ = true

That fixed it!.


Reply to this email directly or view it on GitHubhttps://github.com/Fantomas42/django-blog-zinnia/issues/233#issuecomment-16515423
.

Alex Schliker

coderam commented Apr 17, 2013

Can you merge this into the core django-blog-zinnia repo -- that way I'll
be able to do a simple pip install --upgrade ?

On Wed, Apr 17, 2013 at 11:10 AM, Moises Brenes notifications@github.comwrote:

I was investigating how to fix that cloning zinnia, and I see
django.utils.timezone.now() convert that object datetime but it depends if
settings.USE_TZ is enabled so I did then I fixed that.
settings.py

USE_TZ = true

That fixed it!.


Reply to this email directly or view it on GitHubhttps://github.com/Fantomas42/django-blog-zinnia/issues/233#issuecomment-16515423
.

Alex Schliker

@ksysctl

This comment has been minimized.

Show comment
Hide comment
@ksysctl

ksysctl Apr 17, 2013

@coderam I didn't any change in Zinnia code, just enable USE_TZ in your settings

ksysctl commented Apr 17, 2013

@coderam I didn't any change in Zinnia code, just enable USE_TZ in your settings

@Fantomas42

This comment has been minimized.

Show comment
Hide comment
@Fantomas42

Fantomas42 Apr 26, 2013

Owner

Hi,

thank you for the bug report, I confirm the issue,
some tests need to be done when USE_TZ is set to False.

Regards

Owner

Fantomas42 commented Apr 26, 2013

Hi,

thank you for the bug report, I confirm the issue,
some tests need to be done when USE_TZ is set to False.

Regards

@Fantomas42

This comment has been minimized.

Show comment
Hide comment
@Fantomas42

Fantomas42 Apr 29, 2013

Owner

Note this bug is related to Django 1.5.x only

Owner

Fantomas42 commented Apr 29, 2013

Note this bug is related to Django 1.5.x only

jrutila pushed a commit to jrutila/django-blog-zinnia that referenced this issue Sep 19, 2013

Fix Entry.get_absolute_url when USE_TZ is set to False #233
Conflicts:
	zinnia/models_bases/entry.py
	zinnia/tests/__init__.py

jrutila pushed a commit to jrutila/django-blog-zinnia that referenced this issue Sep 19, 2013

jrutila pushed a commit to jrutila/django-blog-zinnia that referenced this issue Sep 19, 2013

jrutila pushed a commit to jrutila/django-blog-zinnia that referenced this issue Sep 19, 2013

jrutila pushed a commit to jrutila/django-blog-zinnia that referenced this issue Sep 19, 2013

Complete the tests of view with USE_TZ alternatively set to True and …
…False, closes #233

Conflicts:
	zinnia/tests/views.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment