django/django — pull request #1040 by mrmachine (2013-05-03 14:05:12+00:00)
Title: Fixed #20348 -- Consistently handle Promise objects assigned to model fi...

...elds.

Currently, all `Promise` objects are 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 calls
`_proxy____cast()` on `Promise` objects to convert any type of promise to a
real value. All subclasses now call `super().get_prep_value()` first to
ensure that they have a real value to work with.

This also facilitates the creation of custom fields like `PickleField`, which
*can* store Promise objects, to override this behaviour.