diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-09-29 14:39:56 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-09-29 23:24:09 +0200 | 
| commit | ccd7055b5d94f60eb6a8974f530b526fa2405e0b (patch) | |
| tree | ebf1550ddd540e9478c3e1b570e0a0fee59bf526 /ishtar_common/models.py | |
| parent | 9f44f4dd6cdaeb44addf5cc8f2d15a581f1c3e89 (diff) | |
| download | Ishtar-ccd7055b5d94f60eb6a8974f530b526fa2405e0b.tar.bz2 Ishtar-ccd7055b5d94f60eb6a8974f530b526fa2405e0b.zip  | |
✨ more robust templates (don't crash on missing values) - add fields for file templates - number_to_words and float_format filters for templates
Diffstat (limited to 'ishtar_common/models.py')
| -rw-r--r-- | ishtar_common/models.py | 5 | 
1 files changed, 5 insertions, 0 deletions
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)  | 
