Fixed #30958 -- Used a clearer example in the Cast() docs.
This commit is contained in:
parent
85efc14a2e
commit
4cb15450ad
|
@ -39,10 +39,12 @@ Usage example::
|
||||||
|
|
||||||
>>> from django.db.models import FloatField
|
>>> from django.db.models import FloatField
|
||||||
>>> from django.db.models.functions import Cast
|
>>> from django.db.models.functions import Cast
|
||||||
>>> Value.objects.create(integer=4)
|
>>> Author.objects.create(age=25, name='Margaret Smith')
|
||||||
>>> value = Value.objects.annotate(as_float=Cast('integer', FloatField())).get()
|
>>> author = Author.objects.annotate(
|
||||||
>>> print(value.as_float)
|
... age_as_float=Cast('age', output_field=FloatField()),
|
||||||
4.0
|
... ).get()
|
||||||
|
>>> print(author.age_as_float)
|
||||||
|
25.0
|
||||||
|
|
||||||
``Coalesce``
|
``Coalesce``
|
||||||
------------
|
------------
|
||||||
|
|
Loading…
Reference in New Issue