diff --git a/.gitignore b/.gitignore index 654685a0..9a1c4b86 100644 --- a/.gitignore +++ b/.gitignore @@ -109,4 +109,5 @@ venv.bak/ pip-wheel-metadata TODO.md -node_modules/ \ No newline at end of file +node_modules/ +tags diff --git a/django_unicorn/static/js/unicorn.js b/django_unicorn/static/js/unicorn.js index 951d7114..8c9f7f5f 100644 --- a/django_unicorn/static/js/unicorn.js +++ b/django_unicorn/static/js/unicorn.js @@ -41,8 +41,7 @@ const Unicorn = (() => { */ function getCsrfToken() { const csrfElements = document.getElementsByName("csrfmiddlewaretoken"); - - if (csrfElements) { + if (csrfElements && csrfElements.length > 0) { return csrfElements[0].getAttribute("value"); }