Settings¶
karni_settings(globals()) in config/settings.py fills the module with every
Django, DRF, Celery, storage and Karni setting, most of them read from the
environment (.env for host runs, the compose file or CI for the rest).
Anything assigned after the call wins, and any name defined before it is
never overwritten. The call also leaves env, the django-environ reader Karni
reads its own defaults with, in the module, so a setting added after it reads
the environment the same way: FEATURE_X = env.bool("FEATURE_X", default=False).
SILENCED_SYSTEM_CHECKS starts as an empty list, so
SILENCED_SYSTEM_CHECKS += ["karni.W967"] silences a check without a NameError.
Settings read during the call are the exception (see below). So is a setting a
module chooses from the environment first (KARNI_PAYMENTS_PROVIDER): its
environment variable, when set, wins over a value written before the call, such
as karni.yaml's, so .env switches a local try to the test provider.
This page lists the KARNI_* settings. The Django and
DRF settings Karni derives are documented where the feature is.
Settings read during the call¶
A few settings are read while karni_settings() runs, to compute other settings:
KARNI_AUTH_MODE: CSRF_TRUSTED_ORIGINS and CORS_ALLOW_CREDENTIALS (session mode), and django-otp's middleware with KARNI_2FAKARNI_2FA: INSTALLED_APPS and MIDDLEWARE (django-otp)KARNI_SOCIAL_AUTH: INSTALLED_APPS, MIDDLEWARE, AUTHENTICATION_BACKENDS and TEMPLATES (django-allauth)KARNI_SOCIAL_PROVIDERS: INSTALLED_APPS (one django-allauth provider app each)KARNI_FRONTEND_URL: CSRF_TRUSTED_ORIGINS (session mode)KARNI_AUTH_THROTTLE_RATES: REST_FRAMEWORK['DEFAULT_THROTTLE_RATES']KARNI_JSON_LOGS: LOGGING and the structlog rendererKARNI_CACHE: CACHESKARNI_STORAGE: STORAGESKARNI_PEOPLE: INSTALLED_APPS (karni.people, the people contract)KARNI_STATIC_STORAGE: STORAGES['staticfiles']KARNI_SINGLE_PROCESS: KARNI_CACHE, CELERY_TASK_ALWAYS_EAGER, CELERY_BROKER_URL, KARNI_READYZ_CHECKS and KARNI_HEALTH_CHECKS
Set them in .env, define them above the call, or pass them to it:
karni_settings(globals(), KARNI_AUTH_MODE="session"). Assigned below the
call, they cannot change what the call already computed from them, so startup
fails with karni.E508, which names the setting. Every other
setting works below the call. KARNI_ADMIN_LOGO is one of them: the admin
reads it on every request.
All settings¶
| Setting | Env | Default | What it does |
|---|---|---|---|
| Accounts & auth | |||
KARNI_AUTH_MODE |
KARNI_AUTH_MODE |
"jwt" |
jwt (SimpleJWT token pairs) or session (cookie auth + CSRF bootstrap). See accounts. |
KARNI_2FA |
KARNI_2FA |
False |
Enable TOTP two-factor auth with django-otp (needs karni[2fa]). |
KARNI_SOCIAL_AUTH |
KARNI_SOCIAL_AUTH |
False |
Enable social login through django-allauth (karni[social], session mode only). |
KARNI_SOCIAL_PROVIDERS |
KARNI_SOCIAL_PROVIDERS |
[] |
Comma-separated allauth providers to enable, e.g. google,github. |
KARNI_SOCIAL_TOKEN_PROVIDERS |
KARNI_SOCIAL_TOKEN_PROVIDERS |
{} |
Experimental. The providers whose ID tokens sign users in, in both auth modes and without KARNI_SOCIAL_AUTH: {"google": {"client_ids": [...]}, "microsoft": {"client_ids": [...], "tenants": [...], "trusted_tenants": [...]}, "apple": {"client_ids": [...]}}, each with optional require_nonce and class (a dotted IdTokenProvider path). Each one mounts social/<provider>/. Needs karni[social-token]. See sign-in with an ID token. |
KARNI_SOCIAL_TOKEN_SIGNUP |
KARNI_SOCIAL_TOKEN_SIGNUP |
None |
Experimental. What a token without an account does: open creates the account, approval creates it inactive until an administrator activates it, existing refuses (E223). None is open while KARNI_ACCOUNTS_REGISTRATION is on, else existing. |
KARNI_SOCIAL_TOKEN_LINK_VERIFIED |
KARNI_SOCIAL_TOKEN_LINK_VERIFIED |
True |
Experimental. Link a token to the existing account with its email when the provider verified the address. False refuses an account that has a password (E227). |
KARNI_SOCIAL_TOKEN_LEEWAY |
KARNI_SOCIAL_TOKEN_LEEWAY |
60 |
Experimental. Seconds of clock skew allowed on a token's exp, iat and nbf (0 to 300). |
KARNI_SOCIAL_TOKEN_JWKS_TTL |
KARNI_SOCIAL_TOKEN_JWKS_TTL |
21600 |
Experimental. Seconds a provider's signing keys (JWKS) stay in the default cache. An unknown key id fetches them again, at most once a minute per provider. |
KARNI_SOCIAL_TOKEN_JWKS_FETCHER |
"karni.accounts.social_token.fetch_jwks" |
Experimental. Dotted path of the function (url) -> dict that fetches a key set (HTTPS, 5 second timeout by default). |
|
KARNI_EMAIL_OTP |
KARNI_EMAIL_OTP |
False |
Experimental. Sign-in with a code sent by email, in both auth modes: mounts otp/send/ and otp/verify/. Off, both answer 404 and are absent from the OpenAPI schema. See sign in with a code. |
KARNI_EMAIL_OTP_TTL |
KARNI_EMAIL_OTP_TTL |
600 |
Experimental. Seconds a sign-in code lives (60 to 3600). |
KARNI_EMAIL_OTP_LENGTH |
KARNI_EMAIL_OTP_LENGTH |
6 |
Experimental. Digits in a sign-in code (4 to 10). |
KARNI_EMAIL_OTP_MAX_ATTEMPTS |
KARNI_EMAIL_OTP_MAX_ATTEMPTS |
5 |
Experimental. Guesses a sign-in code takes before it dies (1 to 10). A wrong guess that reaches the cap kills the code. |
KARNI_EMAIL_OTP_SIGNUP |
KARNI_EMAIL_OTP_SIGNUP |
None |
Experimental. What a code for an address without an account does: open creates the account when the code is verified, approval creates it inactive until an administrator activates it (E224), existing sends no code. None is open while KARNI_ACCOUNTS_REGISTRATION is on, else existing. |
KARNI_TERMS |
KARNI_TERMS |
None |
Experimental. A versioned terms acceptance gate, as a dict (JSON in the environment): {"version": "2026-11", "url": "/terms/", "required": True}, with optional paths (the URL prefixes it covers, default ["/api/"]) and exempt (more prefixes it leaves open). Set, it mounts terms/ and terms/accept/ and adds terms to me/. While it requires acceptance, a signed-in user gets 403 E245 under paths until they accept the current version, staff included. None gates nothing. See terms acceptance. |
KARNI_FRONTEND_URL |
KARNI_FRONTEND_URL |
"http://localhost:5173" |
The SPA's origin. It is used in account emails and, in session mode, added to CSRF_TRUSTED_ORIGINS, so the browser's origin must match it. |
KARNI_ACCOUNTS_EMAIL_BACKEND |
"karni.accounts.emails.DjangoEmailBackend" |
Dotted path of the AccountsEmailBackend that sends every account email: verification, password reset, email change and the sign-in code. |
|
KARNI_ACCOUNTS_AUTO_LOGIN |
False |
Sign a user in right after registration (skips email verification as a gate). | |
KARNI_ACCOUNTS_REGISTRATION |
KARNI_ACCOUNTS_REGISTRATION |
True |
Whether anyone may open an account through register/. False leaves the route out (404) and out of the OpenAPI schema, for a project whose staff create every account. While it is True, karni.W102 warns for a viewset that lets every signed-in user change and delete every row. See closing registration. |
KARNI_ACCOUNTS_DEFAULT_ROLES |
KARNI_ACCOUNTS_DEFAULT_ROLES |
[] |
Roles (Django groups) every self-registered user starts with, e.g. attendee. |
KARNI_ACCOUNTS_HONEYPOT_FIELD |
KARNI_ACCOUNTS_HONEYPOT_FIELD |
"website" |
Name of the hidden registration field no person fills in. A request that fills it is accepted (202) without creating a user. "" turns the honeypot off. See security. |
KARNI_ROLES |
{ "staff": {"name": "Staff", "system": True, "grants": {"*": "all"}}, "user": {"name": "User", "grants": {"*": "own"}}, "customer": {"name": "Customer", "grants": {"*": "own"}}} |
The project's roles and grants: {slug: {name, description, system, grants: {"app.model:action": scope}}}. Grant patterns take * wildcards, and the scopes are all / own / related:<key> / custom:<name> / tree:<path>. See roles. |
|
KARNI_ROLES_AUTOSYNC |
KARNI_ROLES_AUTOSYNC |
True |
Reconcile the role tables with KARNI_ROLES after every migrate (karni sync-roles does the same by hand). |
KARNI_USER_GRANTS |
KARNI_USER_GRANTS |
False |
Experimental. Per-user grants: while True, each user's UserGrant rows (a pattern and a scope as in KARNI_ROLES, with targets and an expiry) join the grants of their roles, for one more query per request. False (the default) reads no row. See per-user grants. |
KARNI_NAVIGATION |
None |
Experimental. The menu GET /api/navigation/ gives each user: a list of items ({"label", "route", "icon", "order", "requires"}) and groups ({"label", "children": [...]}), or "db" for the NavItem table edited in the admin (add karni.navigation to INSTALLED_APPS), or named menus as a mapping of a name to such a list ({"app": [...], "public": [...], "account": [...]}, read with ?menu=; a list is the app menu). requires is public, authenticated (the default) or a permission pattern as in KARNI_ROLES, so role grants and per-user grants open an item. None (the default) mounts no route. See navigation. |
|
KARNI_NAVIGATION_PAGES |
["frontend/src/routes.tsx"] |
Experimental. The frontend files whose path: entries are the app's pages. karni check reports a menu item whose route none of them serves (E533). [] turns that comparison off. |
|
KARNI_PEOPLE |
KARNI_PEOPLE |
False |
Experimental. True installs the people contract, karni.people: one Person per human and one Organisation per company for every part of the project. Read during the call. karni build writes it when karni.yaml points at people.Person. See people. |
KARNI_PEOPLE_RESOLVER |
"karni.people.services.Resolver" |
Experimental. Dotted path of the Resolver class (or a subclass) people.resolve() finds or creates people with. |
|
KARNI_PEOPLE_LINK_ON_VERIFY |
True |
Experimental. Link an account to the person with its email as soon as the email is verified (sign-up with verification, a sign-in code, a social sign-in with a verified address). False leaves linking to people.link_account(). |
|
KARNI_PEOPLE_API |
True |
Experimental. Route /api/people/, /api/organisations/, /api/people-memberships/ and /api/people-addresses/. False leaves them out, for a project that routes its own viewsets over the people tables. |
|
KARNI_PEOPLE_MERGE_SKIP |
[] |
Experimental. Models a person or organisation merge leaves alone, as "app_label.Model": their rows keep pointing at the merged record. |
|
KARNI_PEOPLE_AUTODISCOVER |
True |
Experimental. Import every installed app's people.py at startup, where a part registers its person facts, merge hooks and erase hooks. False: register them in the part's AppConfig.ready(). |
|
KARNI_TIMELINE_API |
True |
Experimental. Route GET /api/timeline/, a person's, an organisation's or a record's timeline, when karni.timeline is installed. False leaves it out, for a project that mounts its own TimelineView. See timeline. |
|
KARNI_TIMELINE_FROM_EVENTS |
True |
Experimental. Write a timeline entry for each family event whose declaration names a timeline title (declare(..., timeline=...)). False writes entries with timeline.record() only. |
|
KARNI_TIMELINE_PAGE_SIZE |
25 |
Experimental. Timeline entries per page of GET /api/timeline/ when ?limit= is not given. |
|
KARNI_TIMELINE_MAX_PAGE_SIZE |
100 |
Experimental. The largest ?limit= of GET /api/timeline/. |
|
KARNI_TIMELINE_RETENTION_DAYS |
None |
Experimental. Days a timeline entry is kept. None (the default) keeps them all and schedules no pruning. |
|
KARNI_TIMELINE_VISIBILITY |
"karni.timeline.access.Visibility" |
Experimental. Dotted path of the class (a subclass of karni.timeline.access.Visibility) that says which records a request may read, so which timeline entries it sees. |
|
KARNI_PREFERENCES_LOCKED |
{} |
Experimental. Values the deployment fixes, by group then name: {"details": {"currency": "EUR"}, "bookings": {"refund_notice_hours": 48}, "connections": {"crm.deal_timeline": False}, "emails": {...}}. Every read answers the lock, the Settings page shows it read only and a change is refused (E324). karni check refuses a name nobody declared or a value its field refuses (E320). See preferences. |
|
KARNI_PREFERENCES_DEFAULTS |
{} |
Experimental. Values the deployment starts with, in the shape of KARNI_PREFERENCES_LOCKED. The business can change them in Settings. karni build writes the project's name here, and its currency (app.currency) in KARNI_PREFERENCES_LOCKED. |
|
KARNI_PREFERENCES_API |
True |
Experimental. Route /api/preferences/, the API behind the Settings page, when karni.preferences is installed. False leaves it out. |
|
KARNI_PREFERENCES_AUTODISCOVER |
True |
Experimental. Import every installed app's preferences.py and connections.py at startup, where parts declare their settings sections, connections and email kinds. |
|
KARNI_NOTIFY_API |
True |
Experimental. Route /api/inbox/, /api/email-templates/ and /api/notify/unsubscribe/ when karni.notify is installed. False leaves them out, for a project that mounts its own views. See notifications. |
|
KARNI_NOTIFY_CHANNELS |
["email", "inbox"] |
Experimental. The channels the project sends messages on: "email" and "inbox". A kind declared on a channel left out here is not sent there. |
|
KARNI_NOTIFY_PAGE_SIZE |
25 |
Experimental. Notifications per page of GET /api/inbox/ when ?limit= is not given. |
|
KARNI_NOTIFY_MAX_PAGE_SIZE |
100 |
Experimental. The largest ?limit= of GET /api/inbox/. |
|
KARNI_NOTIFY_RETENTION_DAYS |
180 |
Experimental. Days a notification is kept in the inbox, read or not. A daily task deletes older ones. None keeps them all and schedules nothing. |
|
KARNI_NOTIFY_UNSUBSCRIBE_PATH |
"/api/notify/unsubscribe/?token={token}" |
Experimental. Where the unsubscribe link of a marketing email points, after KARNI_FRONTEND_URL: {token} is the signed token. The default is the API's own page, which asks before it unsubscribes. |
|
KARNI_NOTIFY_MOVE_CHANNELS |
["email", "inbox"] |
Experimental. Where the email of a move (moves.<state>.notify in karni.yaml) goes while karni.notify is installed: ["email", "inbox"] (the default), or one of them. |
|
KARNI_ACCOUNTS_TOKEN_TTL |
{ "verify_email": 86400, "reset_password": 3600, "change_email": 86400} |
Lifetime per one-time token purpose (verify_email, reset_password, ...), as timedeltas. |
|
KARNI_ACCOUNTS_LINKS |
{ "verify_email": "{frontend}/auth/verify-email?token={token}", "reset_password": "{frontend}/auth/reset-password?token={token}", "change_email": "{frontend}/auth/confirm-email-change?token={token}"} |
Frontend URL template per token purpose, with {frontend} and {token} placeholders. |
|
KARNI_AUTH_THROTTLE_RATES |
computed (_auth_throttle_rates(env)) |
Per-scope auth throttle overrides as a JSON object. null disables a scope. |
|
| Database & cache | |||
KARNI_CACHE |
KARNI_CACHE |
"redis" |
redis (the default cache at REDIS_URL) or locmem, an in-process cache for a host run without Redis (development only: throttle counters are then per process). |
KARNI_SINGLE_PROCESS |
KARNI_SINGLE_PROCESS |
False |
A deployment of one process, without Redis or a Celery worker: the cache in memory (KARNI_CACHE=locmem), Celery tasks run in the process that sends them (CELERY_TASK_ALWAYS_EAGER, broker memory://), /readyz and /health/ready/ leave the broker and the worker out, and karni.W501 is quiet while WEB_CONCURRENCY is 1. Each only where the project sets no value of its own. Beat does not run: no scheduled task fires. See a small server. |
KARNI_MAIL_DISABLED_KINDS |
KARNI_MAIL_DISABLED_KINDS |
[] |
Experimental. The kinds of email karni.mail does not send, by name (commerce.new_order). A kind is the stable name a part gives each email. |
KARNI_MAIL_SOURCE |
KARNI_MAIL_SOURCE |
"karni.notify.source.NotifySource" |
Experimental. Dotted path of the object (or class) karni.mail asks what a business changed: template(kind) (an email edited in the app), enabled(kind), sender() and, optionally, send(...), which takes over the delivery of every message with a kind. The default, karni.notify.source.NotifySource, keeps edited emails, each person's switches and unsubscribes and the inbox while karni.notify is installed, and reads the files and the preferences contract otherwise. Blank: karni.mail.DefaultSource. See notifications. |
| Files & storage | |||
KARNI_STORAGE |
KARNI_STORAGE |
"local" |
local (filesystem) or s3 (any S3-compatible service, needs karni[s3]). |
KARNI_STATIC_STORAGE |
KARNI_STATIC_STORAGE |
"plain" |
The static files' storage (STORAGES['staticfiles']): plain (the default, the names as written), manifest (karni.storage.static.ManifestStaticStorage: collectstatic gives each file a name with a hash of its content, {% static %} names it, and a web server may let browsers keep it a year, while a file missing from the manifest gets its plain name instead of a failed page) or a dotted path. New site projects set manifest in their production .env. See static and media files. |
| API (karni.api) | |||
KARNI_SEARCH_PROVIDER |
KARNI_SEARCH_PROVIDER |
"karni.api.search.postgres.PostgresSearchProvider" |
Dotted path of the SearchProvider behind ?search=. The PostgreSQL provider falls back to portable search on other databases. |
KARNI_API_MAX_EXPAND_DEPTH |
KARNI_API_MAX_EXPAND_DEPTH |
2 |
Deepest ?expand= path allowed (levels of nesting). |
KARNI_GLOBAL_SEARCH_MIN_LENGTH |
KARNI_GLOBAL_SEARCH_MIN_LENGTH |
2 |
Experimental. The shortest query GET /api/search/ searches for. A shorter one answers no groups. See search across models. |
KARNI_GLOBAL_SEARCH_LIMIT |
KARNI_GLOBAL_SEARCH_LIMIT |
5 |
Experimental. Hits per model GET /api/search/ returns when the request does not say (?limit=). |
KARNI_GLOBAL_SEARCH_MAX_LIMIT |
KARNI_GLOBAL_SEARCH_MAX_LIMIT |
20 |
Experimental. The most hits per model a request may ask for. A larger ?limit= is lowered to it. |
KARNI_GLOBAL_SEARCH_THRESHOLD |
KARNI_GLOBAL_SEARCH_THRESHOLD |
0.3 |
Experimental. The trigram similarity (0 to 1) a row needs on PostgreSQL to match without containing the query. pg_trgm's own pg_trgm.similarity_threshold (0.3) is the floor: the index answers it first. |
KARNI_API_ROUTER |
KARNI_API_ROUTER |
"karni.api.routers.get_default_router" |
Zero-argument factory returning the router karni.api.urls exposes. |
KARNI_PUBLIC_CREATE_RATE |
KARNI_PUBLIC_CREATE_RATE |
"10/hour" |
The limit on each caller (the user, else the client IP) of a create anyone may call (create=Public()), unless the viewset declares throttle = Throttle(create=...). None or "" turns this default off. See rate limits. |
KARNI_PUBLIC_CREATE_HONEYPOT_FIELD |
KARNI_PUBLIC_CREATE_HONEYPOT_FIELD |
"homepage" |
Name of the hidden form field on a public create. A request that fills it is answered 202 and nothing is saved. Off for a model that has a field of that name. "" turns it off. See rate limits. |
| Performance (ADR 0001 Decision 3) | |||
KARNI_MAX_PAGE_SIZE |
KARNI_MAX_PAGE_SIZE |
100 |
Hard cap on ?page_size= for every Karni paginator. |
KARNI_MAX_PAGE_SIZE_FLOOR |
KARNI_MAX_PAGE_SIZE_FLOOR |
25 |
The lowest value KARNI_MAX_PAGE_SIZE may take (the frontend's page size). |
KARNI_QUERY_BUDGET |
{ "list": 8, "retrieve": 8, "create": 12, "update": 12, "partial_update": 12, "destroy": 10, "*": 15} |
Queries allowed per BaseViewSet action ("*" for any other), merged over the defaults. Set it per viewset with query_budget = Budget(...). |
|
KARNI_QUERY_BUDGET_MODE |
KARNI_QUERY_BUDGET_MODE |
"off" |
off, warn (log an exceeded budget) or raise (fail the request, which is what the pytest plugin sets). |
KARNI_QUERY_LOG |
KARNI_QUERY_LOG |
False |
Log each request's query count, duplicates and SQL time (QueryLogMiddleware). |
KARNI_DEMO_MODE |
KARNI_DEMO_MODE |
env.bool("DEMO_MODE", default=False) |
Experimental. Turns demo mode on: only the demo accounts write, the data resets every KARNI_DEMO_RESET_HOURS hours, the sign-in pages list the accounts (GET /api/demo/). Also DEMO_MODE. Needs karni.demo in INSTALLED_APPS and its two middlewares. See demo mode. |
KARNI_DEMO_ACCOUNTS |
KARNI_DEMO_ACCOUNTS |
[] |
Experimental. The demo accounts, one per role: [{"login": "customer@example.com", "label": "Customer", "can": "Place orders.", "roles": ["customer"]}]. Keys: login, label, can, roles (a list or "all"), staff, superuser, password. Empty: the one account karni seed makes. Reported by E950. |
KARNI_DEMO_SEED |
KARNI_DEMO_SEED |
env.int("DEMO_SEED", default=42) |
Experimental. The fixed seed every demo reset uses, so the data is the same each time. Also DEMO_SEED. |
KARNI_DEMO_RESET_HOURS |
KARNI_DEMO_RESET_HOURS |
env.int("DEMO_RESET_HOURS", default=24) |
Experimental. Hours between two demo resets, and how old data may be at boot. Also DEMO_RESET_HOURS. |
KARNI_DEMO_RESET_CHECK_SECONDS |
KARNI_DEMO_RESET_CHECK_SECONDS |
60 |
Experimental. How often a worker asks whether a demo reset is due. One worker resets, under a lock. |
KARNI_DEMO_RESET_STAMP |
KARNI_DEMO_RESET_STAMP |
env("DEMO_RESET_STAMP", default="") |
Experimental. The file that records the last demo reset. Empty: next to the SQLite database, else <BASE_DIR>/data/demo-reset.json. Also DEMO_RESET_STAMP. |
KARNI_DEMO_APP_INDEX |
KARNI_DEMO_APP_INDEX |
env("DEMO_APP_INDEX", default="") |
Experimental. The built React app's index.html that karni.demo.urls.app_urls() serves. Empty: <BASE_DIR>/frontend/dist/index.html. Also DEMO_APP_INDEX. |
KARNI_DEMO_KEEP_APPS |
None |
Experimental. App labels whose rows a demo reset keeps. None: the accounts, roles, content types, sessions, the token blacklist and the beat schedule. |
|
KARNI_DEMO_OPEN_PATHS |
[] |
Experimental. Paths anyone may write to in demo mode, besides sign-in, refresh, sign-out and accept-terms. An exact path or a prefix ending in *, for example ["/api/contact/*"]. |
|
KARNI_DEMO_LOCKED_PATHS |
[] |
Experimental. Paths no demo account may write to, besides the accounts API and the admin's user and role tables. Same pattern rule as KARNI_DEMO_OPEN_PATHS. |
|
KARNI_DEMO_APP_RESERVED |
[] |
Experimental. First path segments the demo's React page never answers, added to api, health, the admin, static and media, for example ["payments"]. |
|
KARNI_DEMO_WRITE_RULE |
"" |
Experimental. Dotted path of f(request) -> Refusal \| None that replaces karni.demo.guard.refusal. |
|
KARNI_DEMO_SEEDER |
"" |
Experimental. Dotted path of f(seed: int) -> str that reseeds the emptied tables on a demo reset. Empty: karni seed --reset with the fixed seed. |
|
KARNI_SEED_LOGINS |
KARNI_SEED_LOGINS |
{} |
Extra karni seed logins with their roles, as JSON: {"organizer@example.com": ["organizer"]}. |
KARNI_API_CACHE |
KARNI_API_CACHE |
False |
Cache BaseViewSet list and retrieve responses, invalidated on every write. See response caching. |
KARNI_API_CACHE_TTL |
KARNI_API_CACHE_TTL |
300 |
Seconds a cached response lives. |
KARNI_API_CACHE_ALIAS |
KARNI_API_CACHE_ALIAS |
"default" |
The Django cache alias responses are stored in. |
KARNI_AGGREGATE_MAX_GROUPS |
KARNI_AGGREGATE_MAX_GROUPS |
1000 |
Experimental. The most groups one GET <resource>/aggregate/ returns. A request that makes more is refused (E387): send top or narrow it with filters. See aggregations. |
KARNI_API_CACHE_FLUSH |
KARNI_API_CACHE_FLUSH |
None |
A daily full flush of the response cache through Celery beat: "HH:MM", or "HH:MM Area/City" for a timezone other than Celery's. None (the default) schedules nothing. |
KARNI_API_CACHE_LEGACY_HEADER |
KARNI_API_CACHE_LEGACY_HEADER |
True |
Also send the deprecated X-Karni-Cache header, with a deprecation warning once per process. X-Cache replaces it. Set it to False once nothing reads the old header. Removed with the header in 1.0. |
| Admin (karni.admin + django-unfold) | |||
KARNI_ADMIN_AUTODISCOVER |
KARNI_ADMIN_AUTODISCOVER |
True |
Register every unregistered model in the admin at startup (karni.admin). |
KARNI_ADMIN_GRANTS_OPEN_PAGES |
KARNI_ADMIN_GRANTS_OPEN_PAGES |
True |
A role's grant (app.model:<action>) opens that model's admin page for that action, inside the grant's scope. False restores the 0.4.0 rule: only Django's model permissions open pages. Signing in to the admin still needs is_staff. See admin. |
KARNI_GENERATOR |
KARNI_GENERATOR |
"Karni" |
The <meta name="generator"> value Karni's public pages carry ({% karni_seo %}), so tools that list a site's technologies see Karni. It names no version on purpose. "" turns it off and keeps a design's own tag. |
KARNI_ADMIN_LOGO |
KARNI_ADMIN_LOGO |
env("KARNI_ADMIN_LOGO", default="") or None |
Logo for the admin header and login: karni for Karni's mark, or {"light": <static path>, "dark": ..., "icon": ...}. Leaving it unset keeps the text header. See admin. |
KARNI_THEME_CSS |
KARNI_THEME_CSS |
"frontend/src/karni-theme.css" |
The project's karni-theme.css (relative to the project root, or absolute), the file karni ui detect writes for the staff app. The admin loads it too, so one file holds the brand. "" turns it off. See theming. |
KARNI_ADMIN_PATH |
KARNI_ADMIN_PATH |
"admin/" |
URL path the scaffold mounts the Django admin at (trailing slash). Set it to something unguessable in production. |
KARNI_ADMIN_EXCLUDE |
KARNI_ADMIN_EXCLUDE |
[ "sessions", "contenttypes", "admin", "auth.Permission", "django_celery_results.ChordCounter"] |
App labels or app_label.ModelName entries the admin leaves out. |
KARNI_ADMIN_BULK_EDIT_MAX |
KARNI_ADMIN_BULK_EDIT_MAX |
500 |
The most rows the admin's Edit selected action changes at once. A larger selection gets a message and nothing changes. See admin. |
KARNI_ADMIN_GUIDE |
KARNI_ADMIN_GUIDE |
True |
Show the Getting started panel on the admin home page, and its entry in the user menu. A user can dismiss it. See admin. |
KARNI_ADMIN_PER_PAGE |
KARNI_ADMIN_PER_PAGE |
25 |
Rows per page on every admin list (25). A model sets its own with AdminMeta.per_page, and a reader picks 25, 50 or 100 with ?per_page=. See admin. |
KARNI_ADMIN_COUNT_ESTIMATE_ABOVE |
KARNI_ADMIN_COUNT_ESTIMATE_ABOVE |
100000 |
On PostgreSQL, a table above this many rows shows an estimated count ("about 1,200,000") instead of running COUNT(*) on every page. 0 always counts exactly. See admin. |
KARNI_ADMIN_LIST_DISPLAY_MAX |
6 |
Columns a derived admin changelist shows at most. | |
KARNI_ADMIN_LIST_FILTER_MAX |
6 |
Sidebar filters a derived admin shows at most. | |
KARNI_ADMIN_SEARCH_MAX |
5 |
Fields a derived admin searches at most. | |
KARNI_ADMIN_SITE |
"django.contrib.admin.site" |
Dotted path of the admin site models are registered on. | |
KARNI_ADMIN_BASE |
"unfold.admin.ModelAdmin" |
Dotted path of the ModelAdmin every derived admin is built on. |
|
KARNI_MATRIX_EXCLUDE |
KARNI_MATRIX_EXCLUDE |
[ "admin", "auth", "contenttypes", "sessions", "sites", "django_celery_beat", "django_celery_results", "token_blacklist", "django_otp", "otp_totp", "otp_static", "account", "socialaccount", "karni_admin", "karni_audit", "karni_transfer", "karni_outbox", "karni_accounts.OneTimeToken", "karni_accounts.Permission", "karni_accounts.SocialIdentity", "karni_accounts.LoginCode"] |
App labels or app_label.ModelName entries the permission matrix leaves out (framework internals by default). |
| Security headers (karni.security) | |||
KARNI_CSP |
KARNI_CSP |
{} |
Directives merged into the Content-Security-Policy every response carries, as a dict (JSON in the environment): sources are added, None removes a directive, e.g. {"font-src": ["https://fonts.gstatic.com"]}. None sends no policy. See security headers. |
KARNI_CSP_REPORT_ONLY |
KARNI_CSP_REPORT_ONLY |
None |
True sends the policy as Content-Security-Policy-Report-Only (reported, not enforced), False enforces it. None follows DEBUG. |
KARNI_PERMISSIONS_POLICY |
KARNI_PERMISSIONS_POLICY |
{} |
Browser features merged into the Permissions-Policy header, each with the origins allowed to use it, e.g. {"geolocation": ["self"]}. None removes a feature. None as the whole value sends no header. |
| Karni knobs | |||
KARNI_HEALTH_CHECKS |
KARNI_HEALTH_CHECKS |
[ "karni.health.checks.check_database", "karni.health.checks.check_cache", "karni.health.checks.check_celery"] |
Dotted paths of the checks /health/ready/ runs (database, cache, Celery by default), comma-separated in the environment. A deployment without a Celery worker leaves karni.health.checks.check_celery out. |
KARNI_HEALTH_CELERY_TIMEOUT |
1.0 |
Seconds the readiness check waits for a Celery worker to answer. | |
KARNI_READYZ_CHECKS |
KARNI_READYZ_CHECKS |
[ "karni.health.checks.check_database", "karni.health.checks.check_cache", "karni.health.checks.check_broker"] |
Dotted paths of the checks /readyz runs: the database, the cache and the Celery broker by default, comma-separated in the environment. Experimental. See deploy. |
KARNI_HEALTH_TIMEOUT |
KARNI_HEALTH_TIMEOUT |
3.0 |
Seconds each readiness check may take before it counts as failed (/readyz and /health/ready/). Experimental. |
KARNI_LOG_QUIET_PATHS |
KARNI_LOG_QUIET_PATHS |
["/healthz", "/readyz", "/health/"] |
Paths whose healthy requests the request log skips, comma-separated in the environment (/healthz, /readyz and /health/ by default). A request that answers 400 or more is still logged. Empty logs all. Experimental. |
| API versions (karni.api.versions, experimental) | |||
KARNI_API_VERSION |
KARNI_API_VERSION |
"" |
The current API version, such as v1: the API is mounted at /api/v1/ when config/urls.py uses karni.api.versions.api_urls(). Empty (the default) leaves the API unversioned. Experimental. See API versions. |
KARNI_API_VERSIONS |
KARNI_API_VERSIONS |
{} |
More versions and what to say about them, as a dict (JSON in the environment): {"v0": {"deprecated": "2026-06-01", "sunset": "2027-01-31", "notes": "https://..."}, "v2": {"router": "myproject.api.v2_router"}}. A deprecated version sends Deprecation, Sunset and Link headers. Experimental. See API versions. |
KARNI_API_UNVERSIONED |
KARNI_API_UNVERSIONED |
"keep" |
What /api/ without a version does once a version is set: keep (the default, it serves the current version), redirect (308 to the current version) or remove (404). Experimental. See API versions. |
KARNI_THUMBNAILER |
"karni.storage.thumbnails.make_thumbnail" |
Dotted path of the function karni.storage.thumbnails renders thumbnails with. |
|
KARNI_VALIDATE |
True |
Validate the merged settings at startup (karni.conf.validation). False skips it. |
|
KARNI_PHONE_COUNTRY_CODE |
KARNI_PHONE_COUNTRY_CODE |
None |
The country code a national phone number gets in a PhoneField (digits, e.g. "44"): "01234 000 111" is stored as +441234000111. Unset, only international numbers (+ or 00) are accepted. See fields. |
KARNI_PHONE_TRUNK_PREFIX |
KARNI_PHONE_TRUNK_PREFIX |
"0" |
The prefix a national number loses before the country code goes in front ("0", "1" in North America, "8" in Russia, "" where the number is dialled as written, as in Italy). |
KARNI_PHONE_NORMALIZER |
"karni.fields.text.default_phone_normalizer" |
Dotted path of the function a PhoneField, its form field and its API field clean a number with: it takes the value as typed and returns E.164, or the value unchanged to reject it. karni.fields.to_e164 holds Karni's rules for your own function. |
|
| Import and export (karni.transfer) | |||
KARNI_IMPORT_INLINE_ROWS |
KARNI_IMPORT_INLINE_ROWS |
500 |
Files with at most this many rows import inside the request. Larger ones run in Celery with progress. |
KARNI_IMPORT_MAX_ROWS |
KARNI_IMPORT_MAX_ROWS |
100_000 |
An upload with more rows than this is refused (E803). Split the file. |
KARNI_EXPORT_MAX_ROWS |
KARNI_EXPORT_MAX_ROWS |
100_000 |
An export with more rows than this is refused (E803). Narrow the filters. |
| Change history (karni.audit) | |||
KARNI_AUDIT_ASYNC |
KARNI_AUDIT_ASYNC |
False |
Write change-history entries from a Celery task instead of inside the request (history becomes eventually consistent). See change history. |
KARNI_AUDIT_RETENTION_DAYS |
KARNI_AUDIT_RETENTION_DAYS |
None |
Days of change history to keep. None (the default) keeps everything and schedules no pruning. |
KARNI_AUDIT_REDACT |
KARNI_AUDIT_REDACT |
["password", "token", "secret", "key"] |
Field-name substrings whose values are never recorded in change history, only that they changed (default password,token,secret,key). |
| Request ids and development capture (karni.tracing / karni.debug) | |||
KARNI_REQUEST_ID_TRUST_HEADER |
KARNI_REQUEST_ID_TRUST_HEADER |
False |
Accept a client's X-Request-ID as the request id with DEBUG off. Turn it on only when the proxy in front overwrites the header on every request. It is ignored when NUM_PROXIES is 0. See capture. |
KARNI_REQUEST_ID_EMAILS |
True |
Stamp X-Karni-Request-ID on every outgoing email (wraps EmailMessage.send) and trace the send in development. |
|
KARNI_DEBUG_CAPTURE |
KARNI_DEBUG_CAPTURE |
True |
With DEBUG on, record requests, failures and a trace under .karni/ for karni trace, karni replay and karni explain --failure. False turns it off, and with DEBUG off it never runs. See capture. |
KARNI_DEBUG_CAPTURE_KEEP |
KARNI_DEBUG_CAPTURE_KEEP |
200 |
How many request records, and how many failure snapshots, .karni/ keeps (the oldest go first). |
KARNI_DEBUG_TRACE_DAYS |
KARNI_DEBUG_TRACE_DAYS |
7 |
Days of .karni/trace/ files to keep. |
| Events & schedules (karni.events / karni.schedule) | |||
KARNI_EVENTS_AUTODISCOVER |
KARNI_EVENTS_AUTODISCOVER |
True |
Import every app's events.py and listeners.py at startup. |
KARNI_SCHEDULES_AUTODISCOVER |
KARNI_SCHEDULES_AUTODISCOVER |
True |
Import every app's schedules.py at startup. |
KARNI_EVENTS_DISPATCHER |
"karni.outbox.dispatch.celery" |
Experimental. Dotted path of the function that hands a committed family event to a worker: (event_id, *, countdown=0). The default queues a Celery task, and the sweep sends what a down broker refused. See family events. |
|
KARNI_EVENTS_INLINE |
KARNI_EVENTS_INLINE |
None |
Experimental. Whether the default dispatcher delivers a committed family event in the process that committed, with no worker: None (the default) follows DEBUG, so development fills the timeline and the inbox at once, True for a small deployment that runs no broker, False keeps Celery. A KARNI_EVENTS_DISPATCHER of your own is used either way. See family events. |
KARNI_EVENTS_MAX_ATTEMPTS |
KARNI_EVENTS_MAX_ATTEMPTS |
8 |
Experimental. Runs of one family event delivery before it is marked failed (1 to 100). Retries wait 10 seconds, then four times longer each time, at most 6 hours. |
KARNI_EVENTS_RETENTION_DAYS |
KARNI_EVENTS_RETENTION_DAYS |
30 |
Experimental. Days a delivered family event stays in the outbox. Events with a pending or failed delivery stay. None keeps them all and schedules no pruning. |
KARNI_PK |
"uuid" |
Experimental. The primary key karni make model writes: uuid (BaseModel) or bigint (BigIntBaseModel). The CLI reads it from a plain KARNI_PK = "bigint" line in config/settings.py, and --pk overrides it per model. Nothing else reads it: each model's class line decides its key. See choosing the key type. |
|
KARNI_ARCHITECTURE |
{ "skip_apps": [], "sql_allowed": ["*/sql/*", "*/migrations/*"], "http_allowed": ["*/services/*", "*/providers/*", "*/tests/*", "conftest.py"], "dup": {"min_statements": 8, "exclude": ["*/migrations/*"]}} |
Configuration of the architecture rules: skip_apps, sql_allowed, http_allowed, dup. See enforcement. |
|
KARNI_CHECK_CACHE |
True |
Experimental. karni check keeps each file check's results under the file's hash in .karni/local/check-cache.json, so an unchanged file is not checked again. False turns it off, a path (relative to the project root) moves it. See the check cache. |
|
KARNI_SUGGESTIONS |
True |
Experimental. karni check and karni doctor print suggestions after the errors and warnings: what Karni could do that the project does by hand, with the file, line and fix (SUG001 to SUG007). They never fail a run. False turns them off for the project. The CLI reads a plain KARNI_SUGGESTIONS = False line in config/settings.py. See suggestions. |
|
KARNI_SCALING_ROWS |
[2, 12] |
Experimental. The two row counts the scaling check compares, small then large. A viewset's query_scaling = Scaling(rows=..., seconds=...) overrides them and sets a time budget. See the scaling check. |
|
KARNI_SEED_BULK_THRESHOLD |
1000 |
Experimental. Rows per model from which karni seed inserts in bulk (a large seed count of karni.yaml). karni seed --volume always does. See volume seeding. |
|
KARNI_SEED_BATCH_SIZE |
2000 |
Experimental. Rows per bulk insert of karni seed (--batch-size overrides it). |
|
KARNI_SEED_LEDGER |
True |
Experimental. karni seed records the row count each table holds after a run in .karni/local/seeded.json, and --volume refuses a table holding rows no seed run left there. False turns it off, a path moves it. |
|
KARNI_EXPLAIN_SEQ_SCAN_ROWS |
1000 |
Experimental. karni queries --explain flags each sequential scan on a table of this many rows or more, with the index that would serve it (PostgreSQL). |
|
KARNI_RULES_CLOCK_SKEW |
300 |
Experimental. Seconds a $now bound of class Karni: bounds forgives, so a browser clock a little ahead or behind the server is not refused. See rules. |
Settings listed as computed derive from others. The defaults of env-backed
settings are what an absent variable yields. KARNI_VALIDATE checks the merged
values at startup and reports every bad one at once (error E504).
Module settings¶
Each module adds its own settings through the karni.settings entry point, read
from its conf.py. They apply once the module is installed (karni add <module>).
Assign them in config/settings.py. A module's README says more about each.
karni explain <SETTING> prints any setting on this page.