gpt4 book ai didi

python - Django 设置文件夹 ImportError

转载 作者:太空宇宙 更新时间:2023-11-03 15:17:35 24 4
gpt4 key购买 nike

我正在为不同设置的文件夹替换 Django 设置文件。该结构的目录如下所示:

    .
├── manage.py
├── media
├── quito_events
│   ├── __init__.py
│   ├── urls.py
│   └── wsgi.py
├── settings
│   ├── __init__.py
│   ├── base.py
│   ├── ci.py
│   ├── local.py
│   ├── production.py
│   ├── staging.py
│   └── test.py
├── static
├── templates
└── users
├── __init__.py
├── models.py
├── tests.py
└── views.py

当我尝试运行时:

django-admin.py shell --settings=quito_events.settings.local


Traceback (most recent call last):
File "/Users/eduardo/.virtualenvs/quito_events/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Users/eduardo/.virtualenvs/quito_events/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
utility.execute()
File "/Users/eduardo/.virtualenvs/quito_events/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/eduardo/.virtualenvs/quito_events/lib/python2.7/site-packages/django/core/management/__init__.py", line 263, in fetch_command
app_name = get_commands()[subcommand]
File "/Users/eduardo/.virtualenvs/quito_events/lib/python2.7/site-packages/django/core/management/__init__.py", line 109, in get_commands
apps = settings.INSTALLED_APPS
File "/Users/eduardo/.virtualenvs/quito_events/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/Users/eduardo/.virtualenvs/quito_events/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in _setup
self._wrapped = Settings(settings_module)
File "/Users/eduardo/.virtualenvs/quito_events/lib/python2.7/site-packages/django/conf/__init__.py", line 134, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'quito_events.settings.local' (Is it on sys.path?): No module named quito_events.settings.local

我做错了什么?

最佳答案

我认为你应该使用:

python manage.py shell --settings=settings.local

关于python - Django 设置文件夹 ImportError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19761330/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com