Set Up and Deploy Your First Django Project

This how-to assumes:

Find a Django project that you want to deploy to Eldarion Cloud.

The requirements of the project are:

If you are not already logged in to Eldarion Cloud from the CLI, run

$ ec login

and type your username (NOT email) and password.

Next, create a site on the Kel cluster:

$ ec sites init

This will create a new site, a production instance (named primary) and write a new gondor.yml to the current directory. You can pass --name if you want to give a custom name.

By default, your personal resource group is used.

In the requirements.txt you will need:

whitenoise # for static files

# for database

Create a new file called Procfile with a mapping of service to command:

web: gunicorn --bind= --log-file - <wsgi-package-name>

Where <wsgi-package-name> is something like myproject.wsgi.

If you need a database, create a PostgreSQL service:

$ ec services create --name=db postgresql


import dj_database_url
    "default": dj_database_url.config(default="postgres://localhost/yourdb")

Note: the default value is just for connecting to your database locally.

To hook up your static files, add Django middleware WhiteNoiseMiddleware to settings.MIDDLEWARE_CLASSES:

  # '',
  # ...

You'll want to add the middleware just after Django's SecurityMiddleware.

If a package.json exists at the top-level directory of your project, you will need to specify the buildpack explicitly in gondor.yml:

site: <resource-group>/<site-name>

This is needed because without it your project will be detected as Node.js.

Deploy your project:

$ ec deploy

If you setup a database, run migrations:

ec run web python migrate

Open the deployed site in your browser:

$ ec open web