I'm using Django and I need to dynamically generate an HTML file from a given template (lab.html):
from django.template import Template, Context
from django.conf import settings
settings.configure()
f = qc.QFile('lab.html')
f.open(qc.QFile.ReadOnly | qc.QFile.Text)
stream = qc.QTextStream(f)
template = stream.readAll()
print(template)
f.close()
t = Template(template)
c = Context({"result": "test"}) #result is the variable in the html file that I am trying to replace
However, I keep getting this odd error that I haven't found anywhere after some research. Any thoughts?
Traceback (most recent call last):
File "/Users/gustavorangel/PycharmProjects/help/HelpUI.py", line 262, in filesSearch
t = Template(template)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/template/base.py", line 184, in __init__
engine = Engine.get_default()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/template/engine.py", line 83, in get_default
"No DjangoTemplates backend is configured.")
django.core.exceptions.ImproperlyConfigured: No DjangoTemplates backend is configured.