Why can't Fabric fabfile see Django settings? -


i have minimal django project contains fabfile tries display django setting:

# fabfile.py fabric.api import * fabric.contrib import django  django.settings_module('conf.settings') django.conf import settings  def set():     print settings.debug 

when run activate virtual environment 'venv' on local host, go project directory '/www/django/testfab/' , run command 'fab set', error:

traceback (most recent call last):   file "/users/smith/venv/django18/lib/python2.7/site-packages/fabric/main.py", line 743, in main     *args, **kwargs   file "/users/smith/venv/django18/lib/python2.7/site-packages/fabric/tasks.py", line 427, in execute     results['<local-only>'] = task.run(*args, **new_kwargs)   file "/users/smith/venv/django18/lib/python2.7/site-packages/fabric/tasks.py", line 174, in run     return self.wrapped(*args, **kwargs)   file "/www/django/testfab/fabfile.py", line 8, in set     print settings.debug   file "/users/smith/venv/django18/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__     self._setup(name)   file "/users/smith/venv/django18/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup     self._wrapped = settings(settings_module)   file "/users/smith/venv/django18/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__     mod = importlib.import_module(self.settings_module)   file "/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module     __import__(name) importerror: no module named conf.settings 

my settings.py file in /www/django/testfab/conf directory:

. ├── conf │   ├── __init__.py │   ├── __init__.pyc │   ├── settings.py │   ├── settings.pyc │   ├── urls.py │   ├── urls.pyc │   ├── wsgi.py │   └── wsgi.pyc ├── fabfile.py ├── fabfile.pyc └── manage.py 

my django_settings_module environment variable set 'conf.settings'.

why fabric not seeing settings.py file? i'm following django integration instructions shown in fabric documentation.

thanks!

solution

as sean hayes points out below, fabric issue. here's how around it:

django.settings_module('conf.settings') django.conf import settings _ = settings.installed_apps 

what directory running fab from? conf won't recognized python module unless /www/django/testfab/ on python path. running fab or python or ./manage.py directory add python path during command's execution.

it's possible conf.settings raising it's own importerror.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -