1. Documentation
  2. Styles & scripts
  3. Loading styles and scripts

Loading styles and scripts

To add custom styles, for example for a custom dashboard, you can load them via the STYLES key in the UNFOLD dictionary in settings.py. This key accepts a list of strings or lambda functions that will be loaded on all pages. JavaScript files can be loaded using a similar approach with the SCRIPTS key.

# settings.py

from django.templatetags.static import static

UNFOLD = {
    "STYLES": [
        lambda request: static("css/styles.css"),
    ],
    "SCRIPTS": [
        lambda request: static("js/scripts.js"),
    ],
}

Note: When deploying to production, make sure to run the python manage.py collectstatic command to collect all static files. This ensures that all custom styles and scripts are properly included in the production build.

© 2023 - 2025 Created by unfoldadmin.com. All rights reserved.