Kalail
Kalail

Reputation: 155

Deploying Django to Heroku using a Windows machine (Production server NOT development server)

I use a Windows machine and have a Django project that I have successfully deployed to Heroku, albeit using the development server. To use a production server Heroku seems to require 'Gunicorn' which does not run on Windows.

This is not good for testing locally before deploying. Does anyone know of any way to get around this? Perhaps some way to use a different server on Heroku?

Upvotes: 7

Views: 2407

Answers (3)

Krzysztof Knigawka
Krzysztof Knigawka

Reputation: 1

All you need to do is specify path to wsgi script from root directory:

$web: gunicorn hellodjango.wsgi

Upvotes: 0

Kalail
Kalail

Reputation: 155

I found a solution that may help when deploying to heroku using a Windows machine. Here is what I do:

Use the development server locally with:

python manage.py runserver

Install and add 'Gunicorn' to your installed apps in settings.py.

Add a process file in the root directory that tells heroku to use the Gunicorn server. This is a file called 'Procfile' with the following code:

web: python kalail/manage.py run_gunicorn --bind=0.0.0.0:$PORT

This way you test using the development server, while heroku uses the Gunicorn server. Make sure you set up serving static files(css/js/imgs) after this, because only the development server automatically serves static files, and the Gunicorn server will need to be configured to do so.

Upvotes: 4

Kenneth Reitz
Kenneth Reitz

Reputation: 8846

You can run the development server locally quite easily:

> python manage.py runserver

Upvotes: 1

Related Questions