Django 1.9 sqlflush错误配置错误

时间:2016-02-19 12:24:25

标签: python django

我试图用

删除我的SQL数据库
django-admin sqlflush

但收到以下错误消息。我无法理解它的反应。

C:\Dropbox\django\group_project>django-admin sqlflush
Traceback (most recent call last):
es\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "c:\users\filip\appdata\local\programs\python\python35-32\lib\site-packag
es\django\db\utils.py", line 157, in databases
    self._databases = settings.DATABASES
  File "c:\users\filip\appdata\local\programs\python\python35-32\lib\site-packag
es\django\conf\__init__.py", line 55, in __getattr__
    self._setup(name)
  File "c:\users\filip\appdata\local\programs\python\python35-32\lib\site-packag
es\django\conf\__init__.py", line 41, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but se
ttings are not configured. You must either define the environment variable DJANG
O_SETTINGS_MODULE or call settings.configure() before accessing settings.

1 个答案:

答案 0 :(得分:1)

您没有告诉django-admin您想要刷新哪个项目的数据库。有几个选择:

  • 请改用python manage.py sqlflush
  • 使用django-admin sqlflush --settings=mysite.settings mysite.settings是您的设置模块。
  • 将操作系统中的DJANGO_SETTINGS_MODULE环境变量设置为mysite.settings,其中mysite.settings是您的设置模块。然后,您可以使用django-admin sqlflush