Changes between Initial Version and Version 1 of Ticket #22536


Ignore:
Timestamp:
Apr 28, 2014, 3:50:11 PM (11 years ago)
Author:
Aymeric Augustin
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 Triage Stage UnreviewedAccepted
  • 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