Installing Django

Django is a popular web application framework built with Python. Opalstack provides a simple installer for Django with Python 3.6 served by uWSGI.

Installation

1

Create a shell user if you have not done so already. You can use an existing shell user if you wish.

2

Click on Applications in the control panel sidebar.

3

Click the button labeled "+ Add Application" in the upper-left corner of the content area.

4

Select Django as the application type.

5

Enter a name for your application in the Name field.

This name will be used to create a subdirectory in your shell user's apps directory such as /home/username/apps/appname.

6

Select the shell user that will host the application.

If you have multiple servers, be sure to select the shell user that is located on the server from which you intend to serve your site.

7

Click the "Add Application" button to save your new application.

8

A notification will appear in the control panel when the application is ready. This may take a minute or longer.

When the installation is complete, the following files and directories will be present in the application directory:

  • start, stop, and kill: scripts to control the operation of your application.
  • env: a directory containing the Python 3 environment used by your application.
  • tmp: a directory containing temporary files used by your application
  • myproject: a directory containing a demo Django project.
  • uwsgi.ini: the uWSGI configuration file for your Django application.

Post-installation steps

Please take the following steps before you begin to use your Django installation:

1

Connect your Django application to a site route in the control panel.

2

Edit the app's myproject/myproject/settings.py to set ALLOWED_HOSTS to include your site's domains.

Example:

ALLOWED_HOSTS = ['domain.com', 'www.domain.com']
3

Run the following commands to restart your Django instance:

/home/username/apps/appname/stop
/home/username/apps/appname/start