Skip to content

Instantly share code, notes, and snippets.

@Alurith
Last active March 20, 2024 16:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alurith/84d331c0ecb7c9a2d575d73ed8f81985 to your computer and use it in GitHub Desktop.
Save Alurith/84d331c0ecb7c9a2d575d73ed8f81985 to your computer and use it in GitHub Desktop.
Django & Htmx
<!-- How to pass django's csrf_token with htmx -->
<!-- FROM: https://www.mattlayman.com/blog/2021/how-to-htmx-django/ -->
<html>
<head><title>Htmx Demo!</title></head>
<body
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
>
{% block main %}{% endblock %}
<script src="https://unpkg.com/htmx.org@1.1.0"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment