2013-11-04 78 views
3

我正在替換不同設置的文件夾的Django設置文件。結構的目錄如下:Django設置文件夾ImportError

. 
    ├── 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 

我做錯了嗎?

+0

quito_events.settings.local文件不存在! – felipsmartins

回答

2

我想你shuld使用:

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

您可以切換到使用manage.py,例如

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

,或者使用django-admin.py具有指定項目路徑,例如

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