Importerror:settings cannot be imported, because environment variable django_settings_module is undefined.
This error occurs because the error report reads: Settings cannot be imported, django_settings_module environment variable is not defined. The following workarounds are available:
1). The simplest solution is to use the Python manager.py shell instead of Python when entering the Python command interface in the current directory of the project or app. Because Django manager.py uses the template loader to automatically find settings.py information in the current directory, the loader file contains the Django settings configuration required by the From Django.conf Import settings import. There will be no error:
$ python manage.py Shell
Python 2.7.1+ (r271:86832, APR 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
(Interactiveconsole)
>>> from Django Import template
>>> t = template. Template (' My name is {{name}}}. ')
>>>
2). If you use the >>> python command, you can either import settings from the correct package yourself and manually configure it:
$ python
Python 2.7.1+ (r271:86832, APR 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>> from Django Import template
>>> from django.conf Import settings
>>> Settings.configure ()
Python Template Error