﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19793	global name 'timezone' is not defined	anonymous	nobody	"NameError at /admin/polls/poll/
global name 'timezone' is not definedRequest Method:	GET
Request URL:	http://127.0.0.1:8000/admin/polls/poll/
Django Version:	1.5c1
Exception Type:	NameError
Exception Value:	global name 'timezone' is not defined
Exception Location:	...../polls/models.py in was_published_recently, line 14
Python Executable:	/usr/bin/python3
Python Version:	3.2.3
############################################################################################################

I suggest to fix the documentation at https://docs.djangoproject.com/en/1.5//intro/tutorial02/

#-------------------------------------------------------------------------------------------
You can improve that by giving that method (in models.py) a few attributes, as follows:


from django.utils import timezone # fix erorr ""global name 'timezone' is not defined""
import datetime                   # fix 

class Poll(models.Model):
    # ...
    def was_published_recently(self):
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
    was_published_recently.admin_order_field = 'pub_date'
    was_published_recently.boolean = True
    was_published_recently.short_description = 'Published recently?'

#---------------------------------------------------------------------------------------------

"	Cleanup/optimization	closed	Documentation	1.5-alpha-1	Normal	wontfix	global name 'timezone' is not defined		Unreviewed	0	0	0	0	0	0
