summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSimon Charette <simon.charette@zapier.com>2019-05-12 17:17:47 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-07-15 10:58:29 +0200
commit1e38f1191de21b6e96736f58df57dfb851a28c1f (patch)
tree99b2c92d87d4d351d1f180e93a543b8903ec28d3 /docs
parentd08e6f55e3a986a8d4b3a58431d9615c7bc81eaa (diff)
Fixed #30446 -- Resolved Value.output_field for stdlib types.
This required implementing a limited form of dynamic dispatch to combine expressions with numerical output. Refs #26355 should eventually provide a better interface for that.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/expressions.txt10
-rw-r--r--docs/releases/3.2.txt9
2 files changed, 18 insertions, 1 deletions
diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt
index 252966bb6c..31d2572288 100644
--- a/docs/ref/models/expressions.txt
+++ b/docs/ref/models/expressions.txt
@@ -484,7 +484,15 @@ The ``output_field`` argument should be a model field instance, like
after it's retrieved from the database. Usually no arguments are needed when
instantiating the model field as any arguments relating to data validation
(``max_length``, ``max_digits``, etc.) will not be enforced on the expression's
-output value.
+output value. If no ``output_field`` is specified it will be tentatively
+inferred from the :py:class:`type` of the provided ``value``, if possible. For
+example, passing an instance of :py:class:`datetime.datetime` as ``value``
+would default ``output_field`` to :class:`~django.db.models.DateTimeField`.
+
+.. versionchanged:: 3.2
+
+ Support for inferring a default ``output_field`` from the type of ``value``
+ was added.
``ExpressionWrapper()`` expressions
-----------------------------------
diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt
index e0e80323e3..aa25b0f511 100644
--- a/docs/releases/3.2.txt
+++ b/docs/releases/3.2.txt
@@ -233,6 +233,15 @@ Models
* The ``of`` argument of :meth:`.QuerySet.select_for_update()` is now allowed
on MySQL 8.0.1+.
+* :class:`Value() <django.db.models.Value>` expression now
+ automatically resolves its ``output_field`` to the appropriate
+ :class:`Field <django.db.models.Field>` subclass based on the type of
+ it's provided ``value`` for :py:class:`bool`, :py:class:`bytes`,
+ :py:class:`float`, :py:class:`int`, :py:class:`str`,
+ :py:class:`datetime.date`, :py:class:`datetime.datetime`,
+ :py:class:`datetime.time`, :py:class:`datetime.timedelta`,
+ :py:class:`decimal.Decimal`, and :py:class:`uuid.UUID` instances.
+
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~