Requested setting INSTALLED_APPS

ponponon發表於2023-04-11

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

相關文章