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,
    "RELOAD_SCRIPT_ELEMENTS": False,
    "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.

RELOAD_SCRIPT_ELEMENTSΒΆ

Whether or not script elements in a template should be β€œre-run” after a template has been re-rendered.

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.