mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Refs #31300 -- Added example to GeneratedField release notes.
This commit is contained in:
parent
45078a204b
commit
0b506bfe1a
@ -134,7 +134,15 @@ Database generated model field
|
|||||||
|
|
||||||
The new :class:`~django.db.models.GeneratedField` allows creation of database
|
The new :class:`~django.db.models.GeneratedField` allows creation of database
|
||||||
generated columns. This field can be used on all supported database backends
|
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
|
More options for declaring field choices
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user