python - django.core.exceptions.ImproperlyConfigured about setting TEMPLATES -


a question django.template

here code:

from django import template t = template.template('my name {{ name }}.') 

but when ran:

traceback (most recent call last):     file "f:/daima/qpython/123.py", line 2, in <module>       t = template.template('my name {{ name }}.')     file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\template\base.py", line 187, in __init__         engine = engine.get_default()     file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\utils\lru_cache.py", line 125, in wrapper         result = user_function(*args, **kwds)     file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\template\engine.py", line 73, in get_default         django_engines = [engine engine in engines.all()     file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\template\utils.py", line 108, in         return [self[alias] alias in self]     file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\template\utils.py", line 105, in __iter__         return iter(self.templates)     file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\utils\functional.py", line 60, in __get__         res = instance.__dict__[self.name] = self.func(instance)     file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\template\utils.py", line 31, in templates         self._templates = settings.templates     file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\conf\__init__.py", line 48, in __getattr__         self._setup(name)     file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\conf\__init__.py", line 42, in _setup         % (desc, environment_variable))  django.core.exceptions.improperlyconfigured: requested setting templates, settings not configured. must either define environment variable django_settings_module or call settings.configure() before accessing settings. 

settings?what's wrong?thanks help

import settings first.

from django.conf import settings settings.configure() django import template t = template.template('my name {{ name }}.') 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -