Tuesday, December 27, 2011

Re: {% elif %} error

On Wed, Dec 28, 2011 at 2:44 PM, Tsung-Hsien <jasoniem9246@gmail.com> wrote:
> Hi,
> I want to use {% elif %}
> my template:
>                        {% if bookmark.hours %}
>                                {{ bookmark.hours }} hours ago
>                        {% elif bookmark.days %}
>                                {{ bookmark.days }} days ago
>                        {% elif bookmark.months %}
>                                {{ bookmark.months }} months ago
>                        {% else %}
>                                 {{ bookmark.years }} years ago
>                        {% endif %}
>
>
> show error:
> Invalid block tag: 'elif', expected 'else' or 'endif'
>
> It can work without elif, if use if...else loop.
>
> my django version is 1.31
>
> how to solve this?

The {% elif %} tag was only recently added to Django; it will be
available in the 1.4 release. Django 1.3 and earlier does not, and
will not ever contain the {% elif %} tag.

You can either develop your site against Django's trunk in the hope
that Django will release 1.4 before you need to roll out your site, or
modify your template to use nested {% if %} statements.

Yours,
Russ Magee %-)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment