在网上取数据,用 Django 存储的时候遇到的错误提示 django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
根据提示给出的两种办法:
define the environment variable DJANGO_SETTINGS_MODULE
import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "你的project.settings")
call settings.configure()
from django.conf import settings settings.configure(DEBUG=True)
关于call settings.configure()官方的说法:
In some cases, you might want to bypass the DJANGO_SETTINGS_MODULE
environment variable. For example, if you’re using the template system
by itself, you likely don’t want to have to set up an environment
variable pointing to a settings module.
Exactly what I want to do.
没用
[...]转发:django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG… 错误的两种解决办法 – Code Life of gladuo[...]