From 3d02f54712bc87f7de46480e01650f8f486c32a5 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 4 Oct 2024 19:51:59 -0700 Subject: [PATCH] Update docs --- docs/advanced_usage.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/advanced_usage.md b/docs/advanced_usage.md index 51f1fde52..c7a7070f3 100644 --- a/docs/advanced_usage.md +++ b/docs/advanced_usage.md @@ -494,17 +494,17 @@ would be filed to `not-invoices/Title.pdf` If the custom field is named "Invoice Number", you would access the value of it via the `get_cf_value` filter due to quirks of the Django Template Language: ```jinja -"invoices/{{ custom_fields|get_cf_value:'Invoice Number' }}" +"invoices/{{ custom_fields|get_cf_value('Invoice Number') }}" ``` -An example using Django's [date filters](https://docs.djangoproject.com/en/5.1/ref/templates/builtins/#date) and others: +You can also use a custom `datetime` filter to format dates: ```jinja invoices/ -{{ custom_fields|get_cf_value:"Date Field"|date:"Y" }}/ -{{ custom_fields|get_cf_value:"Date Field"|date:"m" }}/ -{{ custom_fields|get_cf_value:"Date Field"|date:"d" }}/ -Invoice_{{ custom_fields|get_cf_value:"Select Field" }}_{{ custom_fields|get_cf_value:"Date Field"|cut:"-" }} +{{ custom_fields|get_cf_value("Date Field")|datetime('%Y') }}/ +{{ custom_fields|get_cf_value("Date Field")|datetime('%m') }}/ +{{ custom_fields|get_cf_value("Date Field")|datetime('%d') }}/ +Invoice_{{ custom_fields|get_cf_value:"Select Field" }}_{{ custom_fields|get_cf_value("Date Field")|replace("-", "") }}.pdf ``` This will create a path like `invoices/2022/01/01/Invoice_OptionTwo_20220101.pdf` if the custom field "Date Field" is set to January 1, 2022 and "Select Field" is set to `OptionTwo`.