summaryrefslogtreecommitdiff
path: root/django/db/models/fields/__init__.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-01-29 10:46:36 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-01-29 10:46:36 +0000
commitcf37e4624a967f936ecbb5a4eefc9d38ed9d7892 (patch)
treee44fab9a21ccdf130d85b6fb80c423181663f103 /django/db/models/fields/__init__.py
parent08dd4176edc1019d9168608b55fe777512c641cb (diff)
Fixed #7210 -- Added F() expressions to query language. See the documentation for details on usage.
Many thanks to: * Nicolas Lara, who worked on this feature during the 2008 Google Summer of Code. * Alex Gaynor for his help debugging and fixing a number of issues. * Malcolm Tredinnick for his invaluable review notes. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9792 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/fields/__init__.py')
-rw-r--r--django/db/models/fields/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 7acb84bcc7..274b5b4327 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -194,8 +194,13 @@ class Field(object):
def get_db_prep_lookup(self, lookup_type, value):
"Returns field's value prepared for database lookup."
if hasattr(value, 'as_sql'):
+ # If the value has a relabel_aliases method, it will need to
+ # be invoked before the final SQL is evaluated
+ if hasattr(value, 'relabel_aliases'):
+ return value
sql, params = value.as_sql()
return QueryWrapper(('(%s)' % sql), params)
+
if lookup_type in ('regex', 'iregex', 'month', 'day', 'search'):
return [value]
elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'):
@@ -309,7 +314,7 @@ class Field(object):
if callable(self.default):
defaults['show_hidden_initial'] = True
if self.choices:
- # Fields with choices get special treatment.
+ # Fields with choices get special treatment.
include_blank = self.blank or not (self.has_default() or 'initial' in kwargs)
defaults['choices'] = self.get_choices(include_blank=include_blank)
defaults['coerce'] = self.to_python