]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Documentation: fix filters docs (#10600)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Sun, 17 Aug 2025 16:25:42 +0000 (09:25 -0700)
committerGitHub <noreply@github.com>
Sun, 17 Aug 2025 16:25:42 +0000 (09:25 -0700)
docs/advanced_usage.md

index 76348818910be99281274e91e351d16d24d4636d..378ad424a4a7e3d557ac6e60beb5590a25626538 100644 (file)
@@ -469,12 +469,12 @@ The `get_cf_value` filter retrieves a value from custom field data with optional
 
 ##### Datetime Formatting
 
-The `format_datetime`filter formats a datetime string or datetime object using Python's strftime formatting.
+The `datetime` filter formats a datetime string or datetime object using Python's strftime formatting.
 
 ###### Syntax
 
 ```jinja2
-{{ datetime_value | format_datetime('%Y-%m-%d %H:%M:%S') }}
+{{ datetime_value | datetime('%Y-%m-%d %H:%M:%S') }}
 ```
 
 ###### Parameters
@@ -490,15 +490,11 @@ The `format_datetime`filter formats a datetime string or datetime object using P
 
 ```jinja2
 <!-- Format datetime object -->
-{{ created_at | format_datetime('%B %d, %Y at %I:%M %p') }}
+{{ created | datetime('%B %d, %Y at %I:%M %p') }}
 <!-- Output: "January 15, 2024 at 02:30 PM" -->
 
-<!-- Format datetime string -->
-{{ "2024-01-15T14:30:00" | format_datetime('%m/%d/%Y') }}
-<!-- Output: "01/15/2024" -->
-
 <!-- Custom formatting -->
-{{ timestamp | format_datetime('%A, %B %d, %Y') }}
+{{ custom_fields | get_cf_value('Date Field') | datetime('%A, %B %d, %Y') }}
 <!-- Output: "Monday, January 15, 2024" -->
 ```
 
@@ -508,7 +504,8 @@ for the possible codes and their meanings.
 ##### Date Localization
 
 The `localize_date` filter formats a date or datetime object into a localized string using Babel internationalization.
-This takes into account the provided locale for translation.
+This takes into account the provided locale for translation. Since this must be used on a date or datetime object,
+you must access the field directly, i.e. `document.created`.
 
 ###### Syntax
 
@@ -531,27 +528,27 @@ This takes into account the provided locale for translation.
 
 ```jinja2
 <!-- Preset formats -->
-{{ created_date | localize_date('short', 'en_US') }}
+{{ document.created | localize_date('short', 'en_US') }}
 <!-- Output: "1/15/24" -->
 
-{{ created_date | localize_date('medium', 'en_US') }}
+{{ document.created | localize_date('medium', 'en_US') }}
 <!-- Output: "Jan 15, 2024" -->
 
-{{ created_date | localize_date('long', 'en_US') }}
+{{ document.created | localize_date('long', 'en_US') }}
 <!-- Output: "January 15, 2024" -->
 
-{{ created_date | localize_date('full', 'en_US') }}
+{{ document.created | localize_date('full', 'en_US') }}
 <!-- Output: "Monday, January 15, 2024" -->
 
 <!-- Different locales -->
-{{ created_date | localize_date('medium', 'fr_FR') }}
+{{ document.created | localize_date('medium', 'fr_FR') }}
 <!-- Output: "15 janv. 2024" -->
 
-{{ created_date | localize_date('medium', 'de_DE') }}
+{{ document.created | localize_date('medium', 'de_DE') }}
 <!-- Output: "15.01.2024" -->
 
 <!-- Custom patterns -->
-{{ created_date | localize_date('dd/MM/yyyy', 'en_GB') }}
+{{ document.created | localize_date('dd/MM/yyyy', 'en_GB') }}
 <!-- Output: "15/01/2024" -->
 ```