Fixed #20348 -- Consistently handle Promise objects in model fields.

All Promise objects were passed to force_text() deep in ORM query code.
Not only does this make it difficult or impossible for developers to
prevent or alter this behaviour, but it is also wrong for non-text
fields.

This commit changes `Field.get_prep_value()` from a no-op to one that
resolved Promise objects. All subclasses now call super() method first
to ensure that they have a real value to work with.
This commit is contained in:
Tai Lee 2013-05-04 00:02:10 +10:00 committed by Anssi Kääriäinen
parent 8f5533ab25
commit 31e6d58d46
5 changed files with 195 additions and 26 deletions

View file

@ -253,6 +253,7 @@ class FileField(Field):
def get_prep_value(self, value):
"Returns field's value prepared for saving into a database."
value = super(FileField, self).get_prep_value(value)
# Need to convert File objects provided via a form to unicode for database insertion
if value is None:
return None