Stuck with csrf_token in the tutorial

276 views
Skip to first unread message

wietse

unread,
Nov 9, 2009, 9:35:20 AM11/9/09
to Django users
Hello,

Running django 1.1.1

I'm going through the tutorial and have run into trouble implementing
a form, I get:
TemplateSyntaxError at /polls/1/
Invalid block tag: 'csrf_token'

I've searched around but find it hard to grok what I need to do. In
settings.py I have:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.csrf.middleware.CsrfMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

The form has a `{% csrf_token %}`, and the view is as per the
tutorial:
def detail(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/detail.html',
{'poll': p},
context_instance=RequestContext(request))

Somewhere I read that if I get this kind of error it means I "have
failed to use the tag loader", but I don't know what that means.

Can somebody show me the way?

Wietse

Karen Tracey

unread,
Nov 9, 2009, 9:38:32 AM11/9/09
to django...@googlegroups.com
On Mon, Nov 9, 2009 at 9:35 AM, wietse <wiet...@gmail.com> wrote:

Hello,

Running django 1.1.1

I'm going through the tutorial and have run into trouble implementing
a form, I get:
   TemplateSyntaxError at /polls/1/
   Invalid block tag: 'csrf_token'


csrf_token didn't exist in 1.1.1 -- it's new in the development version.  Please use the 1.1 docs:

http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01

(There is an open ticket to get these properly linked from the documentation page.)

Karen

wietse

unread,
Nov 9, 2009, 9:40:52 AM11/9/09
to Django users
On Nov 9, 3:38 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Mon, Nov 9, 2009 at 9:35 AM, wietse <wiets...@gmail.com> wrote:
> > Running django 1.1.1
>
> > I'm going through the tutorial and have run into trouble implementing
> > a form, I get:
> >    TemplateSyntaxError at /polls/1/
> >    Invalid block tag: 'csrf_token'
>
> csrf_token didn't exist in 1.1.1 -- it's new in the development version.
> Please use the 1.1 docs:
>
> http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01
>
> (There is an open ticket to get these properly linked from the documentation
> page.)

Ok, thanks for the quick response!
Wietse

Mookie

unread,
Dec 13, 2009, 10:59:42 AM12/13/09
to Django users
I just ran into this issue too... seems kind of crazy that the
tutorial doesn't work for the version presented on the "Downloads"
page!
Reply all
Reply to author
Forward
0 new messages