Fixed #30958 -- Used a clearer example in the Cast() docs.

This commit is contained in:
Farhaan Bukhsh 2019-11-10 19:22:21 +05:30 committed by Mariusz Felisiak
parent 85efc14a2e
commit 4cb15450ad
1 changed files with 6 additions and 4 deletions

View File

@ -39,10 +39,12 @@ Usage example::
>>> from django.db.models import FloatField
>>> from django.db.models.functions import Cast
>>> Value.objects.create(integer=4)
>>> value = Value.objects.annotate(as_float=Cast('integer', FloatField())).get()
>>> print(value.as_float)
4.0
>>> Author.objects.create(age=25, name='Margaret Smith')
>>> author = Author.objects.annotate(
... age_as_float=Cast('age', output_field=FloatField()),
... ).get()
>>> print(author.age_as_float)
25.0
``Coalesce``
------------