Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

Commit 6e43ff7

Browse files
committed
fall back to import string if can't be resolved from template context
1 parent 3ec654a commit 6e43ff7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

django_view_composer/templatetags/view_composer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ def render(self, context):
6565
# get the view from template tag options
6666
if "resolve_view" in self.options:
6767
# view needs to be resolved from the template context
68-
resolved = template.Variable(self.options["resolve_view"]).resolve(context)
69-
view_class = import_string(resolved)
68+
try:
69+
resolved = template.Variable(self.options["resolve_view"]).resolve(context)
70+
view_class = import_string(resolved)
71+
except:
72+
# finally try and import without string, e.g., unquoted module name
73+
view_class = import_string(self.options["resolve_view"])
7074
else:
7175
view_class = self.options["view"]
7276

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django_view_composer"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
description = "Django template tags to include views inside other views"
55
authors = ["Josh Higgins <josh@joshh.info>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)