https://htmx.org logo
I ran into a little thing today. I generate an inp...
# 🔥-django-htmx
i
I ran into a little thing today. I generate an input tag inside of the
td
tag. This is great because I can submit individual forms corresponding to a row and column index without submitting an entire row at one time. The problem is that the HTML snippet that is returned has a different CSRF tag once the form is submitted. How do I return a code snippet with the same CSRF tag? I'm thinking of using this little script to do that for me instead of doing it using the Django template. https://justdjango.com/blog/dynamic-forms-in-django-htmx#create-a-base-html-file
Copy code
<script>
      document.body.addEventListener('htmx:configRequest', (event) => {
        event.detail.headers['X-CSRFToken'] = '{{ csrf_token }}';
      })
    </script>