Django Apps§

To run your Django projects and apps in Unit:

  1. Install Unit with the appropriate Python language module version.

  2. If you haven’t already done so, create your Django project and apps where you usually store them.

  3. Prepare Unit configuration for your update. To obtain an initial template, query the control API:

    # curl --unix-socket /path/to/control.unit.sock \
           http://localhost/config/ > config.json


    Control socket path may vary; run unitd --help or see Startup for details.

    This creates a JSON file with Unit’s current settings; update it with your project settings as follows.

    Suppose you use a basic directory structure for your Django project:

    |-- app1/
    |   |-- ...
    |-- app2/
    |   |-- ...
    `-- project/
        |-- ...

    Edit the JSON file, adding a listener in listeners and pointing it to your project’s file in applications. Your project and apps will run on the listener’s IP and port at their respective URL paths. If you use a virtual environment for your project, reference it as home within your app definition object.

        "listeners": {
            "": {
                "pass": "applications/django_project"
        "applications": {
            "django_project": {
                "type": "python 3",
                "path": "/home/django/project/",
                "home": "/home/django/venv/",
                "module": "project.wsgi"

    Here, the top-level project directory becomes path; its child project and the in it are imported via module. If you reorder your directories, set up path and module accordingly.

  4. Upload the updated configuration:

    # curl -X PUT --data-binary @config.json --unix-socket \
           /path/to/control.unit.sock http://localhost/config

    After a successful update, your project and apps should be available on the listener’s IP address and port:

    $ curl
    $ curl