SmileyChris

Django manage.py bash alias

Rambling on about Django 82 months ago.

Here's a small little alias which I use every day in my Django development (put them at the end of your ~/.bashrc or somewhere else that'll work):

alias dj='python manage.py'
alias djr='dj runserver'

Now, whenever you need to start your development server, you only have to type djr. To do a different management task such as a syncdb, you'd just type dj syncdb. It's all pretty obvious, but sometimes it's the little things which make life easier :)

Leave a comment or see my other ramblings.

Comments (5)

Amit Upadhyay said: (82 months ago)

You should mention that django comes with bash completion support for django's django-admin.py and manage.py!

:) Chris said: (82 months ago)

Yea, but I've never found typing the command the difficult bit. ;)
Good additional point though.

David, biologeek said: (82 months ago)

Clever, I hadn't thought about that but it will make my life easier, thanks.

William McVey said: (80 months ago)

I do most of my django app development outside of site's startproject directory hierarchy. I've found that it's actually quite nice to be able to execute 'manage.py' in whatever directory I happen to be in at the time using python's -m option. For example:

python -m manage syncdb

This depends on my PYTHONPATH being set up correctly, but really liberates me from being constrained to a particular "project directory".

owen said: (79 months ago)

how isntruct manage.py syncdb inner the file example:

from django.db import models
from juan import manage
manage.py syncdb

class Editorial(models.Model):
nombre = models.CharField(maxlength=30)
Res at my email: owen-2345@hotmail.com

Leave a comment