⚙️ Settings reference
All Django Headless settings live in the HEADLESS dictionary in your Django settings. Every key is optional, and a key that is not a setting is reported by the system check headless.W005. This is the full dictionary with the defaults:
# mysite/settings.py
HEADLESS = {
"BOOT_LOG": None,
"VERSION_CHECK": True,
"AUTH_SECRET_KEY": None,
"AUTH_READ_ONLY_SECRET_KEY": None,
"AUTH_SECRET_KEY_HEADER": "X-Secret-Key",
"DEFAULT_RENDERER_CLASSES": None,
"DEFAULT_PARSER_CLASSES": None,
"DEFAULT_AUTHENTICATION_CLASSES": None,
"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAdminUser"],
"DEFAULT_FILTER_BACKENDS": ["headless.rest.filters.LookupFilter"],
"DEFAULT_PAGINATION_CLASS": None,
"PAGE_SIZE": None,
"MAX_PAGE_SIZE": 100,
"MAX_EXPANSION_DEPTH": 2,
"SEARCH_PARAM": None,
"ORDERING_PARAM": None,
"SCHEMA": False,
"SCHEMA_TITLE": "API",
"SCHEMA_DESCRIPTION": "",
"SCHEMA_VERSION": "1.0.0",
"DEFAULT_SERIALIZER_CLASS": "rest_framework.serializers.ModelSerializer",
"FILTER_EXCLUSION_SYMBOL": "~",
"FILTER_TRUE_VALUES": ["true", "1", "on"],
"FILTER_FALSE_VALUES": ["false", "0", "off"],
"FILTER_NULL_VALUES": ["null", "none", "empty"],
"FILTER_DISALLOWED_LOOKUPS": ["regex", "iregex"],
"NON_FILTER_FIELDS": [
"search",
"limit",
"page",
"fields",
"omit",
"expand",
"ordering",
],
}
BOOT_LOG
Whether the boot log is shown when the project starts. The boot log lists the exposed models, the number of generated routes, and the authentication and permission classes in use.
None(default): shown underrunserverand the WSGI and ASGI servers Gunicorn, Uvicorn, Daphne, Hypercorn, uWSGI, Waitress, Granian and mod_wsgi. Not shown for other management commands, tests, task workers such as Celery, or scripts. With autoreload,runservershows it once, in the process that serves requests.True: always shown. Use it for a server that is not in the list above.False: never shown.
VERSION_CHECK
Whether the boot log checks PyPI for a newer version of Django Headless. The check runs only when the boot log is shown, waits at most five seconds for PyPI and caches the answer for a day (a failed check for five minutes) in your default cache. When PyPI or the cache cannot be reached, the boot log shows the installed version and the project starts as usual.
Set it to False to never contact PyPI, for example on servers without outgoing internet access.
DRF overrides
These settings take the same values as their Django REST Framework counterparts in REST_FRAMEWORK. They apply to the generated routes only and leave your own views untouched.
| Setting | Default |
|---|---|
DEFAULT_RENDERER_CLASSES | None: use REST_FRAMEWORK |
DEFAULT_PARSER_CLASSES | None: use REST_FRAMEWORK |
DEFAULT_AUTHENTICATION_CLASSES | None: use REST_FRAMEWORK |
DEFAULT_PERMISSION_CLASSES | ["rest_framework.permissions.IsAdminUser"] |
DEFAULT_FILTER_BACKENDS | ["headless.rest.filters.LookupFilter"] |
DEFAULT_PAGINATION_CLASS | None: use REST_FRAMEWORK |
PAGE_SIZE | None: use REST_FRAMEWORK |
SEARCH_PARAM | None: use DRF's default, search |
ORDERING_PARAM | None: use DRF's default, ordering |
A setting set to None falls back to REST_FRAMEWORK. DEFAULT_PERMISSION_CLASSES and DEFAULT_FILTER_BACKENDS have their own defaults and never fall back: the generated routes require a staff user and support filtering whatever REST_FRAMEWORK says. Set them under HEADLESS to change them.
# mysite/settings.py
HEADLESS = {
"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.AllowAny"],
"DEFAULT_PAGINATION_CLASS": "headless.rest.pagination.PageNumberPagination",
"PAGE_SIZE": 25,
"SEARCH_PARAM": "q",
}
All these settings take dotted paths and classes.
PAGE_SIZE has no effect without a pagination class; set DEFAULT_PAGINATION_CLASS here or in REST_FRAMEWORK.
SEARCH_PARAM and ORDERING_PARAM apply to DRF's SearchFilter and OrderingFilter when they are in DEFAULT_FILTER_BACKENDS. Subclasses of those filters and other filter backends keep their own parameter names.
MAX_PAGE_SIZE
The largest page size a client can request on the generated routes, with ?limit= for PageNumberPagination and LimitOffsetPagination. Larger values are lowered to it. The default is 100; None removes the maximum, which lets a single request return a whole table.
It replaces the maximum of the pagination class (max_page_size, or max_limit for LimitOffsetPagination) on the generated routes. See Pagination.
MAX_EXPANSION_DEPTH
The deepest relation path a client can expand with FlexibleSerializer, counted in relations: ?expand=category has depth 1, ?expand=category.articles depth 2. Deeper paths answer 400 Bad Request. The default is 2; None allows any depth. The MAXIMUM_EXPANSION_DEPTH setting of drf-flex-fields takes precedence when set.
AUTH_SECRET_KEY, AUTH_READ_ONLY_SECRET_KEY and AUTH_SECRET_KEY_HEADER
The full access key, the read-only key and the header name for SecretKeyAuthentication. The header defaults to X-Secret-Key.
DEFAULT_SERIALIZER_CLASS
The base class for the serializers of exposed models. Set it to headless.rest.serializers.FlexibleSerializer to expand relations and serialize model properties.
Schema settings
SCHEMA adds an OpenAPI schema route next to the generated routes; it is False by default. SCHEMA_TITLE, SCHEMA_DESCRIPTION and SCHEMA_VERSION fill the info of the schema.
Filter settings
These settings configure LookupFilter:
FILTER_EXCLUSION_SYMBOL: the prefix that turns a filter into an exclusion.FILTER_TRUE_VALUES,FILTER_FALSE_VALUES,FILTER_NULL_VALUES: the values read asTrue,FalseandNone.FILTER_DISALLOWED_LOOKUPS: lookups that cannot be used in filters. The default,["regex", "iregex"], blocks regular expressions; see Filtering.NON_FILTER_FIELDS: query parameters that are never read as filters.LookupFilteralso skips the parameters of the other filter backends and the pagination class of a route (such asSEARCH_PARAM,ORDERING_PARAM,limitandoffset), DRF'sformatparameter and theexpand,fieldsandomitparameters. Add any other parameter your views read here.