Skip to content

Instantly share code, notes, and snippets.

@killerswan
Last active December 20, 2015 07:59
Show Gist options
  • Save killerswan/6097742 to your computer and use it in GitHub Desktop.
Save killerswan/6097742 to your computer and use it in GitHub Desktop.

Setting up a Heroku demo project with Django, from Windows

Today I've started an experiment in using Heroku, and found that the instructions Heroku provided were pretty simple! I'm impressed. Although there were several Windows-related kinks you might be interested in me posting about, below.

First, we're following these instructions: https://devcenter.heroku.com/articles/django

Install Heroku's tools and PostgreSQL http://www.postgresql.org/. (I skipped the install of ssh and git: already have them around.)

To begin (I should probably have used the --no-site-packages flag):

virtualenv venv --distribute
.\venv\Scripts\activate.bat
pip install Django psycopg2 dj-database-url

On Windows, with Visual Studio 2010 and ActiveState Python, I had to resolve several issues. First, to deal with vcvarsall.bat:

set VS90COMNTOOLS=%VS100COMNTOOLS%

Then, to make distutils happy, I edited the compiler arguments to add /MANIFESTFILE, like so, in C:\Python27\Lib\distutils\msvc9compiler.py:

           temp_manifest = os.path.join(
                    build_temp,
                    os.path.basename(output_filename) + ".manifest")
            ld_args.append('/MANIFESTFILE:' + temp_manifest)
+++         ld_args.append('/MANIFESTFILE')

Now, to create the Django project (if there's a problem later, requirements.txt can be edited down):

python .\venv\Scripts\django-admin.py startproject hdemo .
python manage.py runserver
pip freeze > requirements.txt

Add the following to the end of settings.py:

import dj_database_url
DATABASES['default'] =  dj_database_url.config()

Create a .\Procfile (the line ending MUST be LF, not CRLF):

web: python manage.py runserver 0.0.0.0:$PORT --noreload

Then, as their instructions say:

git init
git add .
git commit -a -m "hello"
heroku create
git push heroku master
heroku ps:scale web=1
heroku ps
heroku logs
heroku open

Viola! Now I have to make it actually do something. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment