| Version 2 (modified by , 20 years ago) ( diff ) |
|---|
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 magic-removal branch is located in the user's home directory.
MRP=/home/akaihola/magic-removal # MRP stands for Magic-Removal Pythonpath
MR=$MRP/django
MRBIN=$MR/bin
alias mradmin='PYTHONPATH=$MRP $MRBIN/django-admin.py'
mrgrep() {
grep -r --include="*.py" --include="*.html" $* $MR
}
And some useful idioms using these shortcuts:
$ svn up $MRP $ mradmin startproject myproject $ $MRBIN/make-messages.py $ PYTHONPATH=$MRP ipython In [1]:import django In [2]:django.__file__ Out[2]:'/home/akaihola/magic-removal/django/__init__.pyc'