You can make your life a bit easier by defining Unix shell aliases and environment variables and functions for Django paths and commands. They can be set e.g. in $HOME/.bash_aliases to be loaded automatically.

If you have installed Django in your site-packages, you could use something like:

DJ=/usr/lib/python2.4/site-packages/django
DJBIN=$DJ/bin
alias djadmin='$DJBIN/django-admin.py'
djgrep() {
  grep -r --include="*.py" --include="*.html" $* $DJ
}

Then you'll be able to:

$ djadmin startproject myproject
$ $DJBIN/make-messages.py
$ less $DJ/docs/overview.txt
$ djgrep Permissions
/usr/lib/python2.4/site-packages/django/contrib/auth/models.py:77: (_('Permissions'), {'fields': ('is_staff', 'is_active', 'is_superuser', 'user_permissions')}),

Here's another example for those who don't keep their Django tree in PYTHONPATH (e.g. because of using many different Django versions). In this case the trunk branch is located in the user's home directory.

DJP=/home/akaihola/django-trunk  # DJP stands for DJango Pythonpath
DJ=$DJP/django
DJBIN=$DJ/bin
alias djadmin='PYTHONPATH=$DJP $DJBIN/django-admin.py'
djgrep() {
  grep -r --include="*.py" --include="*.html" $* $DJ
}

And some useful mantras using these shortcuts:

$ svn up $DJP
$ djadmin startproject myproject
$ $DJBIN/make-messages.py
$ PYTHONPATH=$DJP ipython
In [1]:import django
In [2]:django.__file__
Out[2]:'/home/akaihola/django-trunk/django/__init__.pyc'
Last modified 18 years ago Last modified on May 21, 2006, 7:25:12 AM
Note: See TracWiki for help on using the wiki.
Back to Top