Django Tips & Tricks #1 - Shell Aliases For Python/Django Developers

Developers and hackers prefer using terminal and spend a lot of time on it. Instead of typing long commands over and over, they can be aliased to shortnames. The shell builtin alias allows users to set aliases.

One of the most used command while setting up development environment is pip install -r requirements.txt This can be aliased to pir.

alias pir='pip install -r requirements.txt

Now to install requirements, type pir and pressing enter. Here are some other aliases related to python which will be useful on a daily basis.

alias py='python'
alias ipy='ipython'
alias py3='python3'
alias ipy3='ipython3'

alias jn='jupyter notebook'

alias wo='workon'
alias pf='pip freeze | sort'
alias pi='pip install'
alias pun='pip uninstall'

alias dj="python"
alias drs="python runserver"
alias drp="python runserverplus"
alias drps="python runserverplus --print-sql"
alias dsh="python shell"
alias dsp="python shell_plus"
alias dsps="python shell_plus --print-sql"
alias dsm="python schemamigration"
alias dm="python migrate"
alias dmm="python makemigrations"
alias ddd="python dumpdata"
alias dld="python loaddata"
alias dt="python test"

Just add the above aliases to your ~/.bashrc or ~/.zshrc. That's it. Hpy alsng!