From ce41a3e736f78b26ae57e524613dfc12569bc08d Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 13 Mar 2006 01:08:04 +0000 Subject: [PATCH] magic-removal: Fixed #1460 -- Fixed pub_date__lt behavior in SQLite. Thanks for the patch, Malcolm Tredinnick git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2517 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/fields/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 2dacd1cc55..4e23d9a5e7 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -351,6 +351,8 @@ class DateField(Field): def get_db_prep_lookup(self, lookup_type, value): if lookup_type == 'range': value = [str(v) for v in value] + elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte', 'ne'): + value = value.strftime('%Y-%m-%d') else: value = str(value) return Field.get_db_prep_lookup(self, lookup_type, value) @@ -399,6 +401,13 @@ class DateTimeField(DateField): value = str(value) return Field.get_db_prep_save(self, value) + def get_db_prep_lookup(self, lookup_type, value): + if lookup_type == 'range': + value = [str(v) for v in value] + else: + value = str(value) + return Field.get_db_prep_lookup(self, lookup_type, value) + def get_manipulator_field_objs(self): return [forms.DateField, forms.TimeField]