CSRF token with htmx in Django templates

<button
  class="btn btn-primary"
  type="button"
  hx-post="{{ object.delete_item_url }}"
  hx-target="#item-{{ object.item.id }}"
  hx-swap="outerHTML"
  hx-trigger="click"
  hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
>
  Delete item
</button>

in the body tag

<body hx-headers='{"X-CSRFToken": "{{csrf_token }}"}'>
  <!-- here comes content -->
</body>

πŸ“Š Create a modern CV
Create a modern CV

Create a modern CV to impress recruiters