Blog / Django

Adding drag and drop image uploads to your Django site in 5 minutes with DropzoneJS

November 28, 2014

I've been using the Django admin to upload images to my site one-by-one for a few weeks now and I've finally decided I've had enough of it and started looking for a Javascript library that will enable me to do bulk uploads.

I still have around 100 or so albums and at least 1,000 more pictures to upload so you can just imagine how tedious that would be. I found this ...

How to disable the 'Invalid HTTP_HOST header' emails in Django

November 22, 2014

Ever get these annoying admin emails?

Invalid HTTP_HOST header: ''. You may need to add u'' to ALLOWED_HOSTS.

Request repr():
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
'HTTP_HOST': '',

The reason you're getting this is because someone's trying to access your site via a host not listed in your ALLOWED_HOSTS setting.  In my case, for this blog, I have ...

Migrating a Django app from MySQL to PostgreSQL

November 6, 2014

We just finished migrating the database for our Django 1.6 app from MySQL to PostgreSQL.  If you have a clean environment this process is as simple as running syncdb and/or migrate to create the tables, truncating the data in those tables, and running the dumpdata and loaddata management commands.  

Here are the steps to do this:

Step 1: Create an empty database in your PostgreSQL instance

CREATE DATABASE dbname OWNER rolename;

Step 2: Create a ...

New Blog Redesign: Now in Django 1.7!

November 1, 2014

I've finally gotten around redesigning my blog and making it more mobile friendly.  This is the third redesign for this blog since I started it back in January 2008.

I decided to completely redo it this time, moving away from the WordPress/PHP/MySQL stack to Django/Python/PostgreSQL.  Feels much cleaner and runs a lot faster.

Since I just wanted something simple, I wrote the backend myself instead of relying on existing Django apps ...

Converting YouTube videos to MP3

July 4, 2014

I was looking for a new Django project to start a few weeks back and I wanted it to be something I could use myself and involves running tasks in the background as I wanted to play around with Celery. I usually use YouTube nowadays to listen to music while I'm working so I figured it might be a good idea to write a web app where a user can enter the video's ...

Ansible Playbook for a Django Stack (Nginx, Gunicorn, PostgreSQL, Memcached, Virtualenv, Supervisor)

April 20, 2014

I decided to create a separate GitHub project for the Ansible playbook I'm currently using to fully provision a production server for my open-source app, GlucoseTracker, so it can be reused by people who are using the same stack.

You can download the playbook here:

The playbook can fully provision an Ubuntu 12.04 LTS server (will test 14.04 soon) from the base image with the following applications ...

How to deploy encrypted copies of your SSL keys and other files with Ansible and OpenSSL

April 5, 2014

I’ve been working on fully automating server provisioning and deployment of my Django app,GlucoseTracker, the last couple of weeks with Ansible. Since I made this project open-source, I needed to make sure that passwords, secret keys, and other sensitive information are encrypted when I push my code to my repository.

Of course, I have the option to not commit them to the repo, but I want to be able to build my entire ...