#7145: 'NoneType' object has no attribute 'year' in admin change list when using date_hierarchy with a date field with null values -------------------------------------+------------------------------------- Reporter: Eric Walstad | Owner: nobody <eric@…> | Status: closed Type: Uncategorized | Version: master Component: contrib.admin | Resolution: Severity: Normal | worksforme Keywords: | Triage Stage: Has patch: 1 | Unreviewed Needs tests: 0 | Needs documentation: 0 Easy pickings: 0 | Patch needs improvement: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by dfraser@…): I had this problem and the cause turned out to be a date of 0000-00-00 and thus an exception at /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7 /site-packages/django/contrib/admin/templatetags/admin_list.py in date_hierarchy, line 350 occurred because of the None value at the head of the list of possible years. The relevant column in the table was defined as NOT NULL, so this is a MySQL related issue due to its defaults and the complexity resulting from them. Forcing a crash would be good because it makes one clean up the data, but a date of 0000-00-00 might be valid in some sense, so perhaps the code in admin_list.py should change? I decided having a value of "unknown" was more appropriate given how the field was used, so I decided not to use the date_hierarchy feature. -- Ticket URL: <https://code.djangoproject.com/ticket/7145#comment:11> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.