Login

pyserver -- runserver alias

Author:
presclark
Posted:
May 19, 2008
Language:
Python
Version:
.96
Score:
-2 (after 4 ratings)

I use Django's built-in development server all the time, but get tired of typing out the command to run it, and if I'm testing some custom admin css/js, I really get tired of typing out the command that correctly directs the middleware to use my admin media dir.

So I added this alias to my .bashrc and when I'm in a project's root, I just type 'pyserver' and the development server fires up, automatically passing an --adminmedia arg if I have some custom admin media for the project (otherwise it's 'runserver' as always).

Note: This relies on the convention that my custom admin media will be in a folder called admin_media that resides at the project's base. Of course, change it to whatever convention you use.

I'm not a bash expert or anything, but this works for me ;)

1
alias pyserver='python manage.py runserver `if ls ./admin_media/ > /dev/null 2>&1; then echo "--adminmedia ./admin_media/"; fi`'

More like this

  1. Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
  3. Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
  5. Help text hyperlinks by sa2812 1 year, 8 months ago

Comments

Please login first before commenting.