0
簡短說明 - 我試圖在python shell中調用from django.middleware import csrf
。 其投擲/顯示消息。導入模塊CSRF問題:Django
見shell代碼:
C:\>python
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> from django import middleware
>>> from django.middleware import csrf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\django\middleware\csrf.py", line 16, in <m
odule>
from django.utils.cache import patch_vary_headers
File "C:\Python27\lib\site-packages\django\utils\cache.py", line 26, in <modul
e>
from django.core.cache import get_cache
File "C:\Python27\lib\site-packages\django\core\cache\__init__.py", line 70, i
n <module>
if DEFAULT_CACHE_ALIAS not in settings.CACHES:
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 53, in __ge
tattr__
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 46, in _set
up
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but setti
ngs are not configured. You must either define the environment variable DJANGO_S
ETTINGS_MODULE or call settings.configure() before accessing settings.
>>>
任何人可以通過這個&瞭如何來解決這個?