diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-11-13 05:33:25 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-11-14 20:22:33 +0100 |
| commit | ddbe5c86e8180edffc2bb3e327da75953a4c6c2c (patch) | |
| tree | 64bd73441f51b2e9fa1bb47e7f9165da594b6590 /docs | |
| parent | 5b1d0a6be06a14d130b2b7fa305dbc9e2a393761 (diff) | |
[5.0.x] Fixed #34944 -- Made GeneratedField.output_field required.
Regression in f333e3513e8bdf5ffeb6eeb63021c230082e6f95.
Backport of 5875f03ce61b85dfd9ad34f7b871c231c358d432 from main
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/fields.txt | 12 | ||||
| -rw-r--r-- | docs/releases/5.0.txt | 6 |
2 files changed, 10 insertions, 8 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index f90283defc..2d13e96459 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -1243,7 +1243,7 @@ when :attr:`~django.forms.Field.localize` is ``False`` or .. versionadded:: 5.0 -.. class:: GeneratedField(expression, db_persist=None, output_field=None, **kwargs) +.. class:: GeneratedField(expression, output_field, db_persist=None, **kwargs) A field that is always computed based on other fields in the model. This field is managed and updated by the database itself. Uses the ``GENERATED ALWAYS`` @@ -1265,6 +1265,10 @@ materialized view. the model (in the same database table). Generated fields cannot reference other generated fields. Database backends can impose further restrictions. +.. attribute:: GeneratedField.output_field + + A model field instance to define the field's data type. + .. attribute:: GeneratedField.db_persist Determines if the database column should occupy storage as if it were a @@ -1274,12 +1278,6 @@ materialized view. PostgreSQL only supports persisted columns. Oracle only supports virtual columns. -.. attribute:: GeneratedField.output_field - - An optional model field instance to define the field's data type. This can - be used to customize attributes like the field's collation. By default, the - output field is derived from ``expression``. - .. admonition:: Refresh the data Since the database always computed the value, the object must be reloaded diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt index b60f7a6c76..db75a6b0a3 100644 --- a/docs/releases/5.0.txt +++ b/docs/releases/5.0.txt @@ -142,7 +142,11 @@ to create a field that is always computed from other fields. For example:: class Square(models.Model): side = models.IntegerField() - area = models.GeneratedField(expression=F("side") * F("side"), db_persist=True) + area = models.GeneratedField( + expression=F("side") * F("side"), + output_field=models.BigIntegerField(), + db_persist=True, + ) More options for declaring field choices ---------------------------------------- |
