Sometimes when dealing with Django Python projects you want to be able to run manage.py from anywhere.

Let’s go for a step by step demo. Basically, we create an entry_point in the package setup.py that runs the code inside the manage function included in the __init__.py file.

Directory for the demoapp:

mkdir /home/jfuente/proyectos/demoapp

Create a virtualenv:

mkvirtualenv demoapp -a /home/jfuente/proyectos/demoapp/

Install Django package inside the virtualenv:

(demoapp)… pip install Django

Start a project named demoapp:

(demoapp) django-admin startproject demoapp

Create/update the __init__.py inside the project path with content:

Now inside the package setup file (setup.py):

Now you just have to install the package in develop mode to test if everything works…

python setup.py develop

Then run the manage.py command by running the demoapp project like.

demoapp

and it’s done..

demoapp running manage.py as entry_point in setup.py
demoapp version and test commands

I’m sure there will be better ways, but that’s the one that works for me.

What’s yours?