Sunday, January 5, 2014

ImproperlyConfigured: Requested setting TEMPLATE_DEBUG, but settings are not configured.

Maybe you want to test your first django template but keep getting this annoying error message. You certainly getting this error because you are misusing the shell. You are using python shell instead of a django managed shell. Saying this, what do i really mean. Suppose you want to test the following template:
>>> from django.template import Context, Template
>>> t = Template("Hello {{ name }}.")
>>> c = Context({"name": "World"})
>>> t.render(c)
Instead of running the above script from the python shell, go the command prompt ( if you are using winodws os)

cmd>django-admin.py startproject dummyProject
cmd> cd dummyProject
dummyProject> python manage.py shell
>>> 
>>> from django.template import Context, Template
>>> t = Template("Hello {{ name }}.")
>>> c = Context({"name": "World !"})
>>> t.render(c)
Hello World !

Congratulation , you just run your first django template.

No comments:

Post a Comment