From ccd7055b5d94f60eb6a8974f530b526fa2405e0b Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 29 Sep 2024 14:39:56 +0200 Subject: ✨ more robust templates (don't crash on missing values) - add fields for file templates - number_to_words and float_format filters for templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ishtar_common/models.py') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index f7512b606..a827fa902 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2310,6 +2310,11 @@ class DocumentTemplate(models.Model): ensure_ascii=False, separators=("", " : "), ).replace(" " * 4, "\t") + # initialize missing values + if filtr: + for k in filtr: + if k not in values: + values[k] = "" engine = IshtarSecretaryRenderer() try: result = engine.render(self.template, **values) -- cgit v1.2.3