Settings¶
All Shrd settings use the SHARD_ prefix in Django settings.
SHARD_STATE_TIMEOUT¶
Default: 86400 (24 hours)
Seconds to keep component state (props, state, slots) in cache.
SHARD_URL_NAMESPACE¶
Default: "shard"
URL namespace for action routes. Must match your include("shard.urls") configuration.
SHARD_AUTODISCOVER¶
Default: True
When True, Shrd imports <app>.components for every installed app at startup.
SHARD_LOAD_ALPINE¶
Default: False
When True, {% shard_scripts %} includes Alpine.js by default. Otherwise pass alpine=True per page:
SHARD_PRELOAD_SCRIPTS¶
Default: True
When True, {% shard_scripts %} emits <link rel="preload" as="script"> hints for HTMX and shard.js (and Alpine when loaded). Disable if your CSP or asset pipeline handles preloading elsewhere:
SHARD_MINIFY_CSS¶
Default: False when DEBUG=True, otherwise True
When True, scoped component CSS is minified before injection. In development, CSS stays readable in DevTools unless you override:
SHARD_MINIFY_CSS = True # force minification in DEBUG
SHARD_MINIFY_CSS = False # force readable CSS in production
SHARD_VIEW_DATA_ALLOWED_COMPONENTS¶
Default: None
Optional global whitelist of component names allowed in view data trees. When None, you must pass allowed_components= to render_view_data() or set allowed_view_components on a ViewTreeComponent subclass.
For security, always restrict which components view data can instantiate. Never pass user-controlled component names without validation.
Context processor¶
Add shard.context_processors.shard to expose SHARD in templates:
Cache configuration¶
Shrd uses Django's default cache. For production:
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.redis.RedisCache",
"LOCATION": os.environ.get("REDIS_URL", "redis://127.0.0.1:6379/1"),
}
}
Static files¶
Run python manage.py collectstatic in production. Shrd assets are under shard/static/shard/.