Skip to content

Instantly share code, notes, and snippets.

@diogosimao
Forked from andybak/intercooler.html
Created March 31, 2019 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diogosimao/5c85aadfea1df85fd47097e6fdf1759c to your computer and use it in GitHub Desktop.
Save diogosimao/5c85aadfea1df85fd47097e6fdf1759c to your computer and use it in GitHub Desktop.
Example of adding Django CSRF token in an page that POSTs using intercooler.
{% extends "custom_base.html" %}
{% block content %}
<form id="defaults" >
<input name="csrfmiddlewaretoken" type="hidden" value="{{ csrf_token }}">
</form>
<table>
{% for row in items %}
<tr>
<td>{{ row.item }}</td>
<td>{{ row.category }}</td>
<td><button ic-include="#defaults" ic-post-to="/api/{{ row.row_type }}/{{ row.id }}/action1/">Action 1</button></td>
<td><button ic-include="#defaults" ic-post-to="/api/{{ row.row_type }}/{{ row.id }}/action2/">Action 2</button></td>
<td><button ic-include="#defaults" ic-post-to="/api/{{ row.row_type }}/{{ row.id }}/action3/">Action 3</button></td>
</tr>
{% endfor %}
</table>
{% endblock %}
{% block scripts %}
{{ block.super }}
<script src="{% static 'js/vendor/intercooler-0.2.0.min.js' %}"></script>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment