Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script src="jquery-3.2.1.min.js"></script>
- </head>
- ...
- <form>
- {% csrf_token %}
- <input type="hidden" id="tk">
- ...
- <button type="button" id="download-button">Download</button>
- </form>
- <script>
- $('#download-button').click(function(){
- $("#tk").val($("[name='csrfmiddlewaretoken']").val());
- $("form").submit();
- });
- $(window).focus(function(){
- if($("#tk").val() == $("[name='csrfmiddlewaretoken']").val()){
- location.reload();
- }
- });
- </script>
- </html>
Add Comment
Please, Sign In to add comment