tags:

views:

123

answers:

4

I have a django project which is laid out like this...

  • myproject
    • apps
    • media
    • templates
    • django
    • registration
    • sorl
    • typogrify

I'd like to change it to this...

  • myproject
    • apps
    • media
    • templates
    • site-deps
      • django
      • registration
      • sorl
      • typogrify

When I attempt it the 'site-dependencies' all break. Is there a way to implement this structure? I tried adding site-deps to the PYTHONPATH without joy...

A: 

Make sure that site-dependencies, django, registration, sorl, and typogrify all have __init__.py files in them.

cpharmston
A: 

How are you importing the packages under site-dependencies?

Slightly off topic to your question, but I never liked the "default" project layout for Django so I have a script that lays my projects out like so:

myproject/
    apps/

    vendor/
    vendor/django/

    config/__init__.py
    config/urls.py
    config/settings/
    config/settings/__init__.py
    config/settings/base.py
    config/settings/hostname.py

    templates/
    media/

    script/manage.py

The included manage.py is tweaked to add config, apps and vendor to python path ('myproject' itself is not in the python path) and to import config/settings/hostname.py as the settings module (where hostname would be the actual host name of the computer). Any 3rd party apps go in vendor (eg, django itself) and apps for this project go in the apps directory.

It's a bit unconventional, but I like the setup.

tvon
+1  A: 

PYTHONPATH searches in the order that the paths are listed

PythonPath "[ '/myproject', '/myproject/site-deps' ] + sys.path"

is not the same as

PythonPath "[ '/myproject/site-deps', '/myproject' ] + sys.path"

The former order fails; perhaps because it figures it's already looked at the site-deps and there's no point in looking again.

The latter order works.

John Mee