Python Template Error

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.