Skip to main content

Posts

Showing posts with the label shell

Django: Executing manage.py from Anywhere

One nice convenience would be to have a way to call manage.py from anywhere within a virtual environment.  For example, if I want to execute 'manage.py shell', it would be nice to be able to execute that from anywhere rather than having to change directory to where manage.py lives. We can already run management commands from anywhere using django-admin by utilizing the --settings flag, but doing this requires a lot of typing. And wrapping the django-admin in a shell script seems inelegant somehow. Instead, I wrote a small python script based off of manage.py.  This can be placed in the ./bin directory in the virtualenv.  The  DjangoManageSettings  object is meant to be customized on a per project basis, and I intend to make it so it can be passed in from a file configuration somewhere. Anyway, thought I would share.  I'm curious to see other approaches to this. # ---------- ${VIRTUAL_ENV}/bin/django_manage.py -------------------------...