Setting up Django Locally on Windows and Deploy to Heroku

19 Aug 2015 | One-minute read


Setting up Django 1.8 with PostgreSQL to run on Heroku - that’s straightforward. Just follow the official Heroku documentation Getting Started with Django on Heroku. But what if you want or need to do development locally on Windows? Then this is the guide for you.

This guide will show you how to setup the following stack:

and how you can develop on Windows and deploy to Heroku Linux.

For this guide, I’ll assume you are starting from scratch - as in you just installed a new copy of Windows. I’ll also try to explain some of the why so when this guide becomes out of date, you can hopefully figure out how to handle new version numbers.

If you just want to final code, grab it from BitBucket.

Why Develop on Windows

Before we get into the details, I want to first talk about why.

Getting Django to run on Windows is harder than on Linux. You often have to find reliable pre-compiled packages. Your development environment will not exactly match your production environment so you may run into issues that are unique to one environment or the other. Remember that even if you boot to Windows, you can still install Linux in a virtual machine, such as VirtualBox, and develop on Linux.

Then why am I explaining how to setup a Windows environment? I sometimes spend long periods of time disconnected from power and running in a virtual machine drains the battery faster. I still maintain a Linux virtual machine for primary development - the Windows environment is secondary.

Think twice before going down the path of Windows as your primary development environment. But if you still want to, I’ll tell you how.

How

There are quite a few steps to get things running, so I’ve split this guide into several parts.

  1. Introduction (this page)
  2. Setup and Run Django+Heroku Locally on Windows
  3. Change from SQLite to PostgreSQL
  4. Split Windows and Linux Configurations