[Python] django-recaptcha and django-csp nonce not working together

Discussão em 'Python' iniciado por Stack, Junho 19, 2025.

  1. Stack

    Stack Membro Participativo

    I am unable to get a django-csp's nonce="{{request.csp_nonce}} to show up inside of django-recaptcha's js_v3.html file.

    CSP_INCLUDE_NONCE_IN=['script-src']

    CSP_SCRIPT_SRC = ["'self'", "https://www.google.com/recaptcha/", "https://www.gstatic.com/recaptcha/" ]

    CSP_FRAME_SRC = [ "https://www.google.com/recaptcha/" ]

    I tried:

    https://github.com/praekelt/django-recaptcha/issues/101

    How to override external app template in Django?

    This is likely due to the templates being rendered within the widget. Widgets use the render as described in FORM_RENDERER. It then loads from the built-in django/forms/templates directory and then loads by installed apps. It does not include TEMPLATES DIRS directories.

    Continue reading...

Compartilhe esta Página