| | 1 | 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. |
| | 2 | |
| | 3 | If you have installed Django in your site-packages, you could use something like: |
| | 4 | {{{ |
| | 5 | DJ=/usr/lib/python2.4/site-packages/django |
| | 6 | DJBIN=$DJ/bin |
| | 7 | alias djadmin='$DJBIN/django-admin.py' |
| | 8 | djgrep() { |
| | 9 | grep -r --include="*.py" --include="*.html" $* $DJ |
| | 10 | } |
| | 11 | }}} |
| | 12 | |
| | 13 | Then 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 | |
| | 22 | 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. |
| | 23 | {{{ |
| | 24 | MRP=/home/akaihola/magic-removal # MRP stands for Magic-Removal Pythonpath |
| | 25 | MR=$MRP/django |
| | 26 | MRBIN=$MR/bin |
| | 27 | alias mradmin='PYTHONPATH=$MRP $MRBIN/django-admin.py' |
| | 28 | mrgrep() { |
| | 29 | grep -r --include="*.py" --include="*.html" $* $MR |
| | 30 | } |
| | 31 | |
| | 32 | }}} |
| | 33 | |
| | 34 | And some useful idioms using these shortcuts: |
| | 35 | {{{ |
| | 36 | $ mradmin startproject myproject |
| | 37 | $ $MRBIN/make-messages.py |
| | 38 | $ PYTHONPATH=$MRP ipython |
| | 39 | In [1]:import django |
| | 40 | In [2]:django.__file__ |
| | 41 | Out[2]:'/home/akaihola/magic-removal/django/__init__.pyc' |
| | 42 | }}} |