1
0
mirror of https://github.com/django/django.git synced 2025-03-09 00:42:40 +00:00

[5.0.x] Refs #31300 -- Added example to GeneratedField release notes.

Backport of 0b506bfe1ab9f1c38e439c77b3c3f81c8ac663ea from main
This commit is contained in:
Paolo Melchiorre 2023-09-20 09:00:30 +02:00 committed by Mariusz Felisiak
parent ab5124c227
commit 7e4c1e8b3d

View File

@ -134,7 +134,15 @@ Database generated model field
The new :class:`~django.db.models.GeneratedField` allows creation of database
generated columns. This field can be used on all supported database backends
to create a field that is always computed from other fields.
to create a field that is always computed from other fields. For example::
from django.db import models
from django.db.models import F
class Square(models.Model):
side = models.IntegerField()
area = models.GeneratedField(expression=F("side") * F("side"), db_persist=True)
More options for declaring field choices
----------------------------------------