Skip to content
Branch: master
Find file Copy path
Find file Copy path
7 contributors

Users who have contributed to this file

@luto @SalocinHB @The-Compiler @jammon @927589452 @Finn0811 @copykatze
199 lines (122 sloc) 3.82 KB
.. author:: Finn <>
.. tag:: lang-python
.. tag:: web
.. tag:: audience-developers



.. tag_list::

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


All relevant legal information can be found here


Your URL needs to be setup:

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


Step 1

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.

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)

Test installation

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

[isabell@stardust ~]$ curl -I localhost:8000
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

.. author_list::
You can’t perform that action at this time.