Requested setting INSTALLED_APPS, but settings are not configured.

File ~/.local/share/virtualenvs/twitter-a7IU1pWC/lib/python3.10/site-packages/django/conf/__init__.py:63, in LazySettings._setup(self, name)
     61 if not settings_module:
     62     desc = ("setting %s" % name) if name else "settings"
---> 63     raise ImproperlyConfigured(
     64         "Requested %s, but settings are not configured. "
     65         "You must either define the environment variable %s "
     66         "or call settings.configure() before accessing settings."
     67         % (desc, ENVIRONMENT_VARIABLE))
     69 self._wrapped = Settings(settings_module)

ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

使用 python shell 调试 Django 是哒咩的

使用 ipython 调试 Django 是哒咩的

使用 django-admin shell 调试 Django 是哒咩的

解决方案:python manage.py shell


universe_king
3.4k 声望680 粉丝