I'm using django.contrib.comments and get '
CSRF token missing or incorrect.' when previewing or submitting a comment. I have:
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
url(r'^comments/', include('django.contrib.comments.urls')),
url(r'^entry/(?P<pk>\d+)/comment', 'rp2.views.entry_comment_add'),
@csrf_protect #does not matter if this is here or not
def entry_comment_add(request, pk):
entry = models.Entry.objects.get(pk=pk)
assert isinstance(entry, models.Entry)
return render(request, 'entry_comment_popup.html', {'entry':entry})
{% extends 'head-plain.html' %}
<!-- entry_comment_popup.html -->
{% load comments %}
{% block content %}
{% render_comment_form for entry %}
{% endblock %}
The HTML looks like it has the csrf security_hash in the proper place:
...