From 87d0d28d172ad55593dc7caddc520ef7dbc4d91f Mon Sep 17 00:00:00 2001 From: Ryan Cheley Date: Sun, 29 Sep 2024 16:28:39 -0700 Subject: [PATCH] Added documentation for single filter for draft PR --- docs/ref/templates/builtins.txt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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``