1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Refs #28643 -- Added Repeat database function.

Thanks Tim Graham and Nick Pope for reviews.
This commit is contained in:
Mariusz Felisiak
2018-04-03 19:36:12 +02:00
committed by GitHub
parent 6141c752fe
commit 55cc26941a
6 changed files with 64 additions and 4 deletions

View File

@@ -855,6 +855,25 @@ Usage example::
>>> print(author.name_code_point)
77
``Repeat``
----------
.. class:: Repeat(expression, number, **extra)
.. versionadded:: 2.1
Returns the value of the given text field or expression repeated ``number``
times.
Usage example::
>>> from django.db.models.functions import Repeat
>>> Author.objects.create(name='John', alias='j')
>>> Author.objects.update(name=Repeat('name', 3))
1
>>> print(Author.objects.get(alias='j').name)
JohnJohnJohn
``Replace``
-----------