我试图用
删除我的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.
答案 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
。