M
M
maxclax2014-12-12 04:07:05
Django
maxclax, 2014-12-12 04:07:05

{% csrf_token %} not visible, why?

Through templatetags I connect the template with the form:

@register.inclusion_tag('loginsys/loginform.html')
def loginform():
    return {}

In the form itself, I display {% csrf_token %}:
<form method="post" action="{% url 'loginsys:login' %}">
{% csrf_token %}
    <input type="text" name="login[username]" id="username" placeholder="Логин" class="inputbox"/>
    <input type="password" name="login[password]" id="password" placeholder="Пароль" class="inputbox"/>
    <input class="button" value="" type="submit"/>
</form>

When submitting the form, I get:
Reason given for failure:
CSRF cookie not set.
Looking through the code, I don't see csrf_token in it. Tell me what is the problem here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2014-12-12
@maxclax

Did you forget to enable middleware? Did you pass RequestContext(request)?
And what for the form through a tag?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question