简体   繁体   中英

Django blocktrans error

I am nearing the final stages of a project and have run into a bit of a hiccup with Django.

It relates to the {% blocktrans %} tag.

How do I enable it to be fully functional in my app, currently if I wrap a piece of text in {% blocktrans %} I get a TemplateSyntaxError message

I have the following in my

TEMPLATE_CONTEXT_PROCESSORS = (
...
"django.core.context_processors.i18n",
...
)

Any help would be appreciated.

For me was like this (windows + python 2.6 + django 1.2.1)

  1. Will result an error(TemplateSyntaxError):

    {% load i18n %}

    {% blocktrans %} My name is {{ user.firstname }} {% endblocktrans %}

  2. Will work:

    {% load i18n %}

    {% blocktrans with user.firstname as hmpf %} My name is {{ hmpf }} {% endblocktrans %}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM