From 6a85c5b3ceed70fdd96a6e5862a9da4f9b466fc3 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Fri, 31 Mar 2023 10:37:12 -0400 Subject: [PATCH] Fixes #12115: Fix rendering config templates from a data file --- docs/release-notes/version-3.5.md | 1 + netbox/extras/models/configs.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.5.md b/docs/release-notes/version-3.5.md index a0c212599ec..2842cfb918f 100644 --- a/docs/release-notes/version-3.5.md +++ b/docs/release-notes/version-3.5.md @@ -75,6 +75,7 @@ Two new webhook trigger events have been introduced: `job_start` and `job_end`. * [#12108](https://github.com/netbox-community/netbox/issues/12108) - Limit the draggable area of widgets to their headers * [#12109](https://github.com/netbox-community/netbox/issues/12109) - Fix migration error when replicating more than 100 job results * [#12112](https://github.com/netbox-community/netbox/issues/12112) - Do not link data source URL for local paths +* [#12115](https://github.com/netbox-community/netbox/issues/12115) - Fix rendering config templates from a data file ### Other Changes diff --git a/netbox/extras/models/configs.py b/netbox/extras/models/configs.py index 4eac1409fc2..632323af0f3 100644 --- a/netbox/extras/models/configs.py +++ b/netbox/extras/models/configs.py @@ -245,7 +245,10 @@ def render(self, context=None): # Initialize the Jinja2 environment and instantiate the Template environment = self._get_environment() - template = environment.from_string(self.template_code) + if self.data_file: + template = environment.get_template(self.data_file.path) + else: + template = environment.from_string(self.template_code) output = template.render(**context) # Replace CRLF-style line terminators