Settings

Unicorn stores all settings in a dictionary under the UNICORN attribute in the Django settings file. All settings are optional.

# settings.py
UNICORN = {
    "APPS": ["unicorn",],
    "CACHE_ALIAS": "default",
    "MINIFY_HTML": False,
    "MINIFIED": True,
    "SERIAL": {
        "ENABLED": False,
        "TIMEOUT": 60,
    },
    "SCRIPT_LOCATION": "after",
}

APPS

Specify the modules to look for components. Defaults to ["unicorn",].

CACHE_ALIAS

The alias to use for caching. Only used by the experimental serialization of requests for now. Defaults to "default".

MINIFY_HTML

Minify the HTML generated by Unicorn in the AJAX request. If set to True and htmlmin is installed HTML will be minified. htmlmin can be installed with Unicorn via poetry add django-unicorn[minify] or pip install django-unicorn[minify]. Defaults to False.

MINIFIED

Provides a way to control if the minified version of the JavaScript bundle (i.e. unicorn.min.js) is used. Defaults to !DEBUG.

SERIAL

Settings for the experimental serialization of requests. Defaults to {}.

ENABLED

Whether slow requests to the same component should be queued or not. Defaults to False.

TIMEOUT

The number of seconds to wait for a request to finish for additional requests to queue behind it. Defaults to 60.

SCRIPT_LOCATION

Where the initial JavaScript data is included on initial render. Two values are currently supported: after and append.

after is the default and will render the JavaScript outside of the HTML component, i.e. it will be output in the same hierarchy as the parent of the HTML component.

append will render the JavaScript inside of the HTML component.