Skip to content

Widgets do not work with CSP #82

@Lapeth

Description

@Lapeth

Content Security Policy (CSP) requires that all script tags be marked with a nonce attribute. Libraries such as django-csp lets us insert this in templates. Django-tempus-dominus inserts a script tag without a nonce, blocking the resource from being used by the browser.

Clunky workaround:
Write script tags as necessary including the nonce:

<script type="text/javascript" nonce="{{request.csp_nonce}}">
    new tempusDominus.TempusDominus(
        document.getElementById("id_datetime")
    );
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions