Project layout and project utilities / libraries?

I got a little confused with the project layout created with Django 1.4. I want to add some global utilities that will be used across the entire project and applications. I tried to add the utils package at the same level of my applications, but Django does not see it.

mysite/
    manage.py
    myapp/
        __init__.py
        models.py
    mysite/
        __init__.py
        settings.py
        urls.py
    utils/
        __init__.py
        shortcuts.py

Any tips / tricks for using such a package of global utilities?

Thanks michael

+3
source share
1 answer

Instead of adding it to PYTHONPATH, which you should do on every machine you install your project on, you can add it to django settings (mysite / settings.py) in the INSTALLED_APPS variable:

INSTALLED_APPS=(myapp, utils)

This leads to adding utils to the python path, so you can do things like:

from utils import shortcuts
0
source

All Articles