Changes between Initial Version and Version 1 of CookBookScriptsAliases


Ignore:
Timestamp:
Apr 25, 2006, 2:44:22 AM (18 years ago)
Author:
Antti Kaihola
Comment:

Created.

Legend:

Unmodified
Added
Removed
Modified
  • CookBookScriptsAliases

    v1 v1  
     1You 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.
     2
     3If you have installed Django in your site-packages, you could use something like:
     4{{{
     5DJ=/usr/lib/python2.4/site-packages/django
     6DJBIN=$DJ/bin
     7alias djadmin='$DJBIN/django-admin.py'
     8djgrep() {
     9  grep -r --include="*.py" --include="*.html" $* $DJ
     10}
     11}}}
     12
     13Then you'll be able to:
     14{{{
     15$ djadmin startproject myproject
     16$ $DJBIN/make-messages.py
     17$ less $DJ/docs/overview.txt
     18$ djgrep Permissions
     19/usr/lib/python2.4/site-packages/django/contrib/auth/models.py:77:            (_('Permissions'), {'fields': ('is_staff', 'is_active', 'is_superuser', 'user_permissions')}),
     20}}}
     21
     22Here'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.
     23{{{
     24MRP=/home/akaihola/magic-removal  # MRP stands for Magic-Removal Pythonpath
     25MR=$MRP/django
     26MRBIN=$MR/bin
     27alias mradmin='PYTHONPATH=$MRP $MRBIN/django-admin.py'
     28mrgrep() {
     29  grep -r --include="*.py" --include="*.html" $* $MR
     30}
     31
     32}}}
     33
     34And some useful idioms using these shortcuts:
     35{{{
     36$ mradmin startproject myproject
     37$ $MRBIN/make-messages.py
     38$ PYTHONPATH=$MRP ipython
     39In [1]:import django
     40In [2]:django.__file__
     41Out[2]:'/home/akaihola/magic-removal/django/__init__.pyc'
     42}}}
Back to Top