ImportError when running Django sampleapp

Issue #15 resolved
Nate Aune
created an issue

I followed the Django quickstart instructions at http://cloudsilverlining.org/django-quickstart.html and when I try to access the site at http://127.0.0.1:8080, I get the following error:

{{{

!python

silver serve .

serving on http://127.0.0.1:8080

Exception happened during processing of request from ('127.0.0.1', 40842) Traceback (most recent call last): File "/srv/silverlining/lib/python2.6/site-packages/paste/httpserver.py", line 1068, in process_request_in_thread self.finish_request(request, client_address) File "/usr/lib/python2.6/SocketServer.py", line 320, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.6/SocketServer.py", line 615, in init self.handle() File "/srv/silverlining/lib/python2.6/site-packages/paste/httpserver.py", line 442, in handle BaseHTTPRequestHandler.handle(self) File "/usr/lib/python2.6/BaseHTTPServer.py", line 329, in handle self.handle_one_request() File "/srv/silverlining/lib/python2.6/site-packages/paste/httpserver.py", line 437, in handle_one_request self.wsgi_execute() File "/srv/silverlining/lib/python2.6/site-packages/paste/httpserver.py", line 287, in wsgi_execute self.wsgi_start_response) File "/srv/silverlining/src/silverlining/silverlining/devel-runner.py", line 185, in call return app(environ, start_response) File "/srv/myapp/lib/python/django/core/handlers/wsgi.py", line 230, in call self.load_middleware() File "/srv/myapp/lib/python/django/core/handlers/base.py", line 33, in load_middleware for middleware_path in settings.MIDDLEWARE_CLASSES: File "/srv/myapp/lib/python/django/utils/functional.py", line 276, in getattr self._setup() File "/srv/myapp/lib/python/django/conf/init.py", line 40, in _setup self._wrapped = Settings(settings_module) File "/srv/myapp/lib/python/django/conf/init.py", line 75, in init raise ImportError("Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'sampleapp.settings' (Is it on sys.path? Does it have syntax errors?): No module named sampleapp.settings

}}}

I added a file sampleapp.pth to the lib/python folder:

{{{ $ cd /srv/myapp/lib/python $ cat sampleapp.pth ../../src/sampleapp }}}

And yes, there is a directory at ../../src/sampleapp that contains the sample Django app that was created.

Comments (2)

  1. Nate Aune reporter

    Another silly problem. I misread the instructions and had a directory src/sampleapp/ that contained all of the files, instead of src/sampleapp/sampleapp. Once I added this intermediary directory, then it worked.

    What's the best way to handle this wonky directory structure with existing Django projects? A bunch of symlinks?

  2. Log in to comment