﻿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
7145	'NoneType' object has no attribute 'year' in admin change list when using date_hierarchy with a date field with null values	Eric Walstad <eric@…>	nobody	"In changeset r7511
{{{
AttributeError
'NoneType' object has no attribute 'year'
}}}
{{{
Exception Type:  	AttributeError
Exception Value: 	'NoneType' object has no attribute 'year'
Exception Location: 	/usr/lib/python2.5/site-packages/django/contrib/admin/templatetags/admin_list.py in date_hierarchy, line 271
}}}

In the following, years is getting set to [None].  That seems to happen when there are null values in the date field, as best I can tell:
{{{
#!python

            years = cl.query_set.dates(field_name, 'year')
            return {
                'show': True,
                'choices': [{
                    'link': link({year_field: year.year}),
                    'title': year.year
                } for year in years]
            }
}}}

Local vars:
{{{
_[3] 	[]
cl 	<django.contrib.admin.views.main.ChangeList object at 0x89c628c>
day_field 	'date_paid__day'
day_lookup 	None
field_generic 	'date_paid__'
field_name 	'date_paid'
link 	<function <lambda> at 0x8b5af44>
month_day_format 	u'F j'
month_field 	'date_paid__month'
month_lookup 	None
year 	None
year_field 	'date_paid__year'
year_lookup 	None
year_month_format 	u'F Y'
years 	[None]
}}}


My temporary work around is to not use date_hierarchy in the admin ui.
"	Uncategorized	closed	contrib.admin	dev	Normal	worksforme			Unreviewed	1	0	0	0	0	0
