diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index d34742f210..97bae1819d 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -2723,7 +2723,7 @@ Truncated strings will end with a translatable ellipsis character ("…"). **Argument:** Number of characters to truncate to -For example: +For example in a template: .. code-block:: html+django @@ -2731,6 +2731,20 @@ For example: If ``value`` is ``"Joel is a slug"``, the output will be ``"Joel i…"``. +For example in Python: + +.. code-block:: python + + from django.template.defaultfilters import truncatechars + + truncated = truncatechars("Joel is a slug", 7) + +If ``value`` is ``"Joel is a slug"``, the output will be ``"Joel i…"``. + +.. function:: truncatechars(value, arg) + + This function truncates a string after ``arg`` number of characters. + .. templatefilter:: truncatechars_html ``truncatechars_html``