Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.


For this guide you should be familiar with the basic concepts of

  • Python and its package manager pip


All relevant legal information can be found here


Your URL needs to be setup:

[isabell@stardust ~]$ uberspace web domain list
[isabell@stardust ~]$

You’ll need your MySQL credentials. Get them with my_print_defaults:

[isabell@stardust ~]$ my_print_defaults client
[isabell@stardust ~]$


Step 1

Install the required uwsgi package with pip.

[isabell@stardust ~]$ pip3.6 install uwsgi --user
[isabell@stardust ~]$

After that, continue with setting it up as a service.

Create ~/etc/services.d/uwsgi.ini with the following content:

command=uwsgi --master --emperor %(ENV_HOME)s/uwsgi/apps-enabled
stderr_logfile = ~/uwsgi/err.log
stdout_logfile = ~/uwsgi/out.log

Create needed folders and files for uwsgi:

[isabell@stardust ~]$ mkdir -p ~/uwsgi/apps-enabled
[isabell@stardust ~]$ touch ~/uwsgi/err.log
[isabell@stardust ~]$ touch ~/uwsgi/out.log
[isabell@stardust ~]$

Tell supervisord to refresh its configuration and start the service:

[isabell@stardust ~]$ supervisorctl reread
uwsgi: available
[isabell@stardust ~]$ supervisorctl update
uwsgi: added process group
[isabell@stardust ~]$ supervisorctl status
uwsgi                            RUNNING   pid 26020, uptime 0:03:14
[isabell@stardust ~]$

If it’s not in state RUNNING, check your configuration.

Step 2

Install django

[isabell@stardust ~]$ pip3.6 install django --user
[isabell@stardust ~]$

Create a django project. We will use “MyDjangoProject” during this guide.

[isabell@stardust ~]$ django-admin startproject MyDjangoProject
[isabell@stardust ~]$

Migrate database

[isabell@stardust ~]$ python3.6 ~/MyDjangoProject/ migrate
[isabell@stardust ~]$


Configure Hostname

Edit ~/MyDjangoProject/MyDjangoProject/ and edit the line ALLOWED_HOSTS = [] to add your host name.


If you need to add multiple host names, separate them with commas like this:

ALLOWED_HOSTS = ['', 'www.isabell.example']


It is recommended to run Django with a database other than the default SQLite once you go into production. Additionally, the SQLite version provided by the underlying CentOS 7 is too old for Django >=2.2. The following step changes the database engine to the better performing MySQL.

Open ~/MyDjangoProject/MyDjangoProject/ and edit the database block to look like this

  'default': {
      'ENGINE': 'django.db.backends.mysql',
          'NAME': 'DB_NAME',
      'USER': 'DB_USER',
      'HOST': 'localhost',

Configure web server


Django is running on port 8000.

To make the application accessible from the outside, configure a web backend:

[isabell@stardust ~]$ uberspace web backend set / --http --port <port>
Set backend for / to port <port>; please make sure something is listening!
You can always check the status of your backend using "uberspace web backend list".
[isabell@stardust ~]$

Setup daemon

To deploy your application with uwsgi, create a file at ~/uwsgi/apps-enabled/myDjangoProject.ini with the following content:


Replace <username> with your username! (4 times)

base = /home/<username>/MyDjangoProject/MyDjangoProject
chdir = /home/<username>/MyDjangoProject

http = :8000
master = true
wsgi-file = %(base)/
touch-reload = %(wsgi-file)
static-map = /static=%(base)/static

app = wsgi

#virtualenv = %(chdir)/venv

plugin = python

uid = <username>
gid = <username>

Test installation

Perform a CURL request to djangos port to see if your installation succeeded:

[isabell@stardust ~]$ curl -I
HTTP/1.1 200 OK
Content-Type: text/html
X-Frame-Options: SAMEORIGIN
Content-Length: 16348
[isabell@stardust ~]$

If you don’t see HTTP/1.1 200 OK check your installation.

Finishing installation

Point your browser to URL and create a user account.

Best practices


Change all default passwords. Look at folder permissions. Don’t get hacked!

Tested with Django 2.0.5, Uberspace 7.1.6

Written by: Finn <>