diff options
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/models/database-functions.txt | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt index b63b4cff4a..ac0c5ea4ec 100644 --- a/docs/ref/models/database-functions.txt +++ b/docs/ref/models/database-functions.txt @@ -1147,18 +1147,19 @@ Returns a random value in the range ``0.0 ≤ x < 1.0``. ``Round`` --------- -.. class:: Round(expression, **extra) +.. class:: Round(expression, precision=0, **extra) -Rounds a numeric field or expression to the nearest integer. Whether half +Rounds a numeric field or expression to ``precision`` (must be an integer) +decimal places. By default, it rounds to the nearest integer. Whether half values are rounded up or down depends on the database. Usage example:: >>> from django.db.models.functions import Round - >>> Vector.objects.create(x=5.4, y=-2.3) - >>> vector = Vector.objects.annotate(x_r=Round('x'), y_r=Round('y')).get() + >>> Vector.objects.create(x=5.4, y=-2.37) + >>> vector = Vector.objects.annotate(x_r=Round('x'), y_r=Round('y', precision=1)).get() >>> vector.x_r, vector.y_r - (5.0, -2.0) + (5.0, -2.4) It can also be registered as a transform. For example:: @@ -1168,6 +1169,10 @@ It can also be registered as a transform. For example:: >>> # Get vectors whose round() is less than 20 >>> vectors = Vector.objects.filter(x__round__lt=20, y__round__lt=20) +.. versionchanged:: 4.0 + + The ``precision`` argument was added. + ``Sign`` -------- |
