Configuration

The following configuration can be provided in your settings.py:

COTTON_DIR
str (default: 'cotton')
Change the default path in your templates directory where cotton components can be placed, for example "components".
COTTON_BASE_DIR
str (default: None)
The base directory where - in addition to the app folders - cotton will search for the "templates" directory (see above). If not set, the BASE_DIR generated by `django-admin startproject` is used as a fallback, if it exists.
COTTON_SNAKE_CASED_NAMES
bool (default: True)
By default cotton will look for snake case versions of your component names. To turn this behaviour off (useful if you want to permit hyphenated filenames) then set this key to False.
Example:
<c-my-button />
True (default)
Filepath: cotton/my_button.html
False
Filepath: cotton/my-button.html
COTTON_ISOLATE_BY_DEFAULT
bool (default: False)
When set to True, every component is rendered with Smart Isolation: it cannot see variables from the surrounding parent template (preventing accidental context leaks), but it does still receive global context-processor output such as request, user, messages, perms and any of your own custom processors.
Processor output is captured once per request and reused across every component on the page — no extra processor invocations regardless of how many components you render.
For total isolation (block context processors too), add the only flag to an individual component.
This setting replaces the experimental COTTON_ENABLE_CONTEXT_ISOLATION flag, which continues to work but emits a DeprecationWarning.