Scaleway Documentationtutorials
django python instant apps

Jump toUpdate content

Deploy your Django application with the Python InstantApp in seconds

Reviewed on 10 May 2021 • Published on 01 July 2015
  • compute
  • apps
  • Python
  • Django
  • Nginx
  • uWSGI

The intended audience of this image is Python developers who want to bootstrap or test a Python application easily, in seconds.

Common packages have been installed:

  • various SCM: git, mercurial, svn
  • system wide dependencies of Python package mysql-python (libmysqlclient-dev, python-dev). You can then run pip install mysql-python.
  • system wide dependencies of Python package psycopg2 (libpq-dev, python-dev). You can then run pip install psycopg2.
  • virtualenv, so you can isolate your development environment

Also, a web environment is bootstrapped so you can deploy your web application easily.

Requirements:

To understand why this image is useful, let’s deploy a simple Django application.

Create and start a new instance using the Python InstantApp

Follow the instructions for creating an Instance. When selecting the image to run on the Instance, ensure that you choose the Python image in the InstantApps tab.

Run a Django web application

This image makes it super easy to deploy your Django application, with nginx and uWSGI. The commands below can also be used to deploy another Python web application.

First of all, install Django and create your project:

$> pip install django$> cd /var/www$> django-admin startproject my_django_project

Then, enable the nginx template to configure the virtualhost:

$> ln -s /etc/nginx/sites-available/my_website /etc/nginx/sites-enabled/

Also, you need to enable the uWSGI template:

$> ln -s /etc/uwsgi/apps-available/my_django_project.ini /etc/uwsgi/apps-enabled/

Finally, restart services:

$> service uwsgi restart$> service nginx restart

And you can open your browser and visit your IP to view your super new website!

Important:

You may want to customize the nginx and uWSGI configuration templates we provided! We created these files only to help, because it’s always a pain to setup a web stack.

Useful links:

Installing a database

This image doesn’t contain databases, but you can install one according to your preference:

To install MySQL, run:

$> apt-get install mysql-server

And/or PostgreSQL:

$> apt-get install postgresql