Django

Code

Changeset 3223

Show
Ignore:
Timestamp:
06/28/06 06:37:17 (2 years ago)
Author:
mtredinnick
Message:

Fixed #1754, #2211, #2192 -- allow date filtering comparisons to use strings as
well as date objects. Fixed a couple of admin crashes as well.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/fields/__init__.py

    r3183 r3223  
    412412        if lookup_type == 'range': 
    413413            value = [str(v) for v in value] 
    414         elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte', 'ne')
     414        elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte', 'ne') and hasattr(value, 'strftime')
    415415            value = value.strftime('%Y-%m-%d') 
    416416        else: 
  • django/trunk/tests/modeltests/lookup/models.py

    r3170 r3223  
    5858>>> Article.objects.filter(headline__startswith='Blah blah').count() 
    59590L 
     60 
     61# Date and date/time lookups can also be done with strings. 
     62>>> Article.objects.filter(pub_date__exact='2005-07-27 00:00:00').count() 
     633L 
    6064 
    6165# in_bulk() takes a list of IDs and returns a dictionary mapping IDs