Daniel Nill
Daniel Nill

Reputation: 5747

Problem validating django project no module named 'project name'

Unfortunately the traceback on this one hasn't been very enlightening so hopefully someone can point me in the right direction.

When I try to run syncdb, validate, or runserver I get the following traceback:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 436, in execute_manager
    setup_environ(settings_mod)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 419, in setup_environ
    project_module = import_module(project_name)
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
ImportError: No module named osps

Where osps is the name of my project. The manage.py file hasn't been touched and looks to be the standard file django generates on creation of a project. osps is referenced twice in my settings.py. Once on the database name declaration as as os.path.dirname(__file__)+'/osps.db' and once in the standard ROOT_URLCONF = 'OSPS.urls'.

Additionally a quick project wide search doesn't turn up any import osps statements. Any suggestions?

Upvotes: 3

Views: 4923

Answers (1)

Thomas
Thomas

Reputation: 11888

make sure your directories look like this.

-- osps\
 |-- app1\
 | `-- ...
 |-- __init__.py   <- makes this a module
 |-- manage.py
 |-- settings.py
 `-- urls.py

worst comes to worst, put this line at the top of settings.py:

import os.path.dirname as d, sys.path as p; p.insert(0,d(d(__file__)))

this will put your project's parent folder at the top of the import chain. better though is to remove all references to your toplevel project. It should not be part of any references between apps anyway. This is best practice for pluggable/reusable apps. in which case,

import os.path.dirname as _d, sys.path as _p; _p.insert(0,_d(__file__))

Upvotes: 4

Related Questions