更新时间:2022-04-05 08:49:49
您的 manage.py
正在引用一个应用程序( notifications
)。由于Django环境尚未设置,Django会抱怨DJANGO_SETTINGS_MODULE被设置。
Yourmanage.py
is referencing an application (notifications
). This forces Django to complain about DJANGO_SETTINGS_MODULE being set because the Django environment hasn't been set up yet.
顺便说一下,您可以手动强制环境设置,但是老实说,我会不要在manage.py中执行此操作。这在我看来并不是一个很好的做法。
Incidentally, you can force the enviroment setup manually, but honestly I wouldn't do this in manage.py. That's not really a good practice in my opinion.
以下是您可以从任何应用程序(或程序中)手动设置Django环境:
Here is how you can manually setup the Django environment from within any app (or program for that matter):
# set up the environment using the settings module
from django.core.management import setup_environ
from myapp import settings
setup_environ(settings)