Changes between Initial Version and Version 1 of Ticket #22536


Ignore:
Timestamp:
04/28/2014 03:50:11 PM (16 months ago)
Author:
aaugustin
Comment:

We discussed this ticket on IRC. I believe it's an acceptable solution, provided there's an adequate comment and a MySQL-specific test. The code isn't complex, so this change is low risk.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #22536

    • Property Needs documentation unset
    • Property Patch needs improvement unset
    • Property Needs tests unset
    • Property Triage Stage changed from Unreviewed to Accepted
  • Ticket #22536 – Description

    initial v1  
    11I ran into a non-obvious exception while using the date-based generic views. get_previous_day / get_next_day were raising an AttributeError ('NoneType' object has no attribute 'astimezone') in the following code when the view was called with the earliest item in the system:
    22
     3{{{
    34        try:
    45            result = getattr(qs[0], date_field)
     
    1112                result = timezone.localtime(result)
    1213            result = result.date()
    13 
     14}}}
    1415
    1516This error wasn't immediately obvious because the query shouldn't have been able to return a NULL. Looking at the data revealed the problem: a small number of records on my test instance had invalid dates in MySQL (0000-00-00) which were included by the __lt query but subsequently converted into None by the ORM.
Back to Top