from django import template
t = template.Template("My name is {{ name }}.")
c = template.Context({'name' : 'Yasmika'})
print(t.render(t))
I'm learning the basics of Python Django. When I'm trying to run Django template, Python interpreter gives me this error. How can I fix this?
C:\Users\YasmikaSH\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/YasmikaSH/Desktop/lern_django/lern_django/test2.py
Traceback (most recent call last):
File "C:/Users/YasmikaSH/Desktop/lern_django/lern_django/test2.py", line 3, in <module>
t = template.Template("My name is {{ name }}.")
File "C:\Users\YasmikaSH\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\template\base.py", line 184, in __init__
engine = Engine.get_default()
File "C:\Users\YasmikaSH\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\template\engine.py", line 76, in get_default
django_engines = [engine for engine in engines.all()
File "C:\Users\YasmikaSH\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\template\utils.py", line 89, in all
return [self[alias] for alias in self]
File "C:\Users\YasmikaSH\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\template\utils.py", line 86, in __iter__
return iter(self.templates)
File "C:\Users\YasmikaSH\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\YasmikaSH\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\template\utils.py", line 29, in templates
self._templates = settings.TEMPLATES
File "C:\Users\YasmikaSH\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\conf\__init__.py", line 56, in __getattr__
self._setup(name)
File "C:\Users\YasmikaSH\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\conf\__init__.py", line 39, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting TEMPLATES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.