In this article, I’ll list some tools I use for developing web applications in Python/Django and describe my workflow. I’ll also share a few tweaks I’ve come up with to make my life easier. I realize my Django development setup is ever evolving and will probably change significantly as I discover new tools and techniques. So, I’ll make sure to edit this article when that happens. For now, here we go:
Let’s start with a list of tools that I use for my Django work:
- OS: Ubuntu 15.10
- Text Editor: Sublime Text
- Browser: Google Chrome/Firefox
- Guake Terminal
- Django Debug Toolbar
Now, I’ll go through each one in turn and describe how I use it:
I haven’t done any Django on Windows, but it seems it would be extremely inconvenient due to the lack of a proper terminal out of the box. I’m sure there are ways to overcome that, but I feel like anyone doing Django should be on Linux or Mac OS.
Even though I’ve made a few attempts to switch to Vim as my main editor, at this point in time I’m still married to Sublime Text. I always use the latest build and install a few essential plugins through the Package Control. Here are some plugins I use for my Django work:
Besides packages, I have a bunch of custom snippets and keyboard shortcuts to make my life easier. I’ve been planning to put all my Sublime configuration files on github for a while now, but haven’t quite got to it yet. When I do, I’ll put a link here.
These are my browsers of choice. I like how smooth and fast Chrome is, so that’s what I opt for most of the time. But as a web developer, there is simply no excuse for not testing your code on multiple browsers.
I have replaced the default Terminal application with the Guake Terminal. This makes the terminal very handy and easily accessible with the F12 key. I can open a new terminal tab with Ctrl+Shift+T and have keyboard shortcuts to navigate the tabs with Ctrl+right arrow and Ctrl+left arrow combinations. I use Ctrl+Shift+w to close tabs. I generally have two tabs open: one for keeping the server running and the other one for doing advanced Git work — the simple stuff I do with Sublime Text’s Git plugin — as well as Django stuff like migrations and accessing the Python shell.
I have a lot of very useful bash aliases defined in my .bash_aliases file. The most common ones I use are:
rs: python3 manage.py runserver
mig: python3 manage.py makemigrations; python3 manage.py migrate
mshell: python3 manage.py shell
Here’s a partial list of my aliases:
alias ealias="sudo vim ~/.bash_aliases"
alias salias="source ~/.bash_aliases"
alias www='cd /var/www/'
alias mkv='mkvirtualenv --python=python3'
alias gs="git status"
alias gd="git diff"
alias gc="git commit -m"
alias gca="git commit -a -m"
alias gl="git log --oneline"
alias ga="git add"
alias gpush="git push origin master"
alias gpull="git pull origin master"
alias rs="python3 manage.py runserver"
alias mig="python3 manage.py makemigrations;python3 manage.py migrate"
alias createsuperuser="python3 manage.py createsuperuser"
alias mshell="python3 manage.py shell"
alias test="python3 manage.py test"
I’ve been meaning to look into the zsh terminal for a while now. If I do, I’ll write a blog post about it.
I generally use it when I’m in the terminal and need to edit a file quickly without bothering Sublime Text about it. I generally edit requirements files, .gitignore and bash aliases in Vim.
Django Debug Toolbar
This is a very nifty little toolbar that’s incredibly useful during Django development. Not only does it let me view static files and templates being loaded on any webpage, it also shows the database queries being made. I’ve optimized quite a few things using information from this toolbar.
I hope this was interesting and useful. If you have any tips or tricks for my workflow, I’d love to hear about it in the comments.