Refs #31300 -- Added example to GeneratedField release notes.

This commit is contained in:
Paolo Melchiorre 2023-09-20 09:00:30 +02:00 committed by GitHub
parent 45078a204b
commit 0b506bfe1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

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
----------------------------------------