Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » 'if' statement improperly formatted [RSS Feed]

#1 Jan. 23, 2011 13:25:09

vamsy k.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

'if' statement improperly formatted


Hi,

I'm getting the below exception from the third line in the snippet.
This works fine on one server while fails on the other. Any help?

Exception Type: TemplateSyntaxError
Exception Value: 'if' statement improperly formatted

{% range 1:32 as i %}
{% ifequal i curdattime.day %}
{% if i < 10 %}
<option
value="{{i}}" selected="selected">0{{i}}</option>
{% else %}
<option
value="{{i}}" selected="selected">{{i}}</option>
{% endif %}
{% else %}
{% if i < 10 %}
<option
value="{{i}}">0{{i}}</option>
{% else %}
<option
value="{{i}}">{{i}}</option>
{% endif %}
{% endifequal %}
{% endrange %}

P.S: "range" is a custom tag which I've picked up online for range
looping in the template.

--
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+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 23, 2011 13:40:03

Karen T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

'if' statement improperly formatted


On Sun, Jan 23, 2011 at 8:25 AM, vamsy krishna <badguitar...@gmail.com>wrote:

> I'm getting the below exception from the third line in the snippet.
> This works fine on one server while fails on the other. Any help?
>
> Exception Type: TemplateSyntaxError
> Exception Value: 'if' statement improperly formatted
>
> {% range 1:32 as i %}
> {% ifequal i curdattime.day
> %}
> {% if i < 10 %}
>

That's the error message you get if you try to use "smart" if (a Django 1.2
feature:http://docs.djangoproject.com/en/1.2/releases/1.2/#smart-if-tag)
with an earlier release of Django. You either need to stick to the if tag
syntax supported by your lower-level release or upgrade your Django install
to 1.2.

Karen
--http://tracey.org/kmt/--
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+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 23, 2011 14:06:05

vamsy k.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

'if' statement improperly formatted


Oh ok. Thanks for the direction. The server on which it fails uses
django 1.1. I was looking through the documentation for the same and
did not find anything related to relational operators in the django
templates. Any idea how can I do '<', '>' in 1.1?

On Jan 23, 6:39 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Sun, Jan 23, 2011 at 8:25 AM, vamsy krishna <badguitar...@gmail.com>wrote:
>
> > I'm getting the below exception from the third line in the snippet.
> > This works fine on one server while fails on the other. Any help?
>
> > Exception Type:         TemplateSyntaxError
> > Exception Value:        'if' statement improperly formatted
>
> >                                        {% range 1:32 as i %}
> >                                                {% ifequal i curdattime.day
> > %}
> >                                                        {% if i < 10 %}
>
> That's the error message you get if you try to use "smart" if (a Django 1.2
> feature:http://docs.djangoproject.com/en/1.2/releases/1.2/#smart-if-tag)
> with an earlier release of Django. You either need to stick to the if tag
> syntax supported by your lower-level release or upgrade your Django install
> to 1.2.
>
> Karen
> --http://tracey.org/kmt/--
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+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Jan. 23, 2011 14:39:47

vamsy k.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

'if' statement improperly formatted


I've added the smart if feature to my custom template tags to get this
working.

On Jan 23, 7:05 pm, vamsy krishna <badguitar...@gmail.com> wrote:
> Oh ok. Thanks for the direction. The server on which it fails uses
> django 1.1. I was looking through the documentation for the same and
> did not find anything related to relational operators in the django
> templates. Any idea how can I do  '<', '>' in 1.1?
>
> On Jan 23, 6:39 pm, Karen Tracey <kmtra...@gmail.com> wrote:
>
> > On Sun, Jan 23, 2011 at 8:25 AM, vamsy krishna
> > <badguitar...@gmail.com>wrote:
>
> > > I'm getting the below exception from the third line in the snippet.
> > > This works fine on one server while fails on the other. Any help?
>
> > > Exception Type:         TemplateSyntaxError
> > > Exception Value:        'if' statement improperly formatted
>
> > >                                        {% range 1:32 as i %}
> > >                                                {% ifequal i curdattime.day
> > > %}
> > >                                                        {% if i < 10 %}
>
> > That's the error message you get if you try to use "smart" if (a Django 1.2
> > feature:http://docs.djangoproject.com/en/1.2/releases/1.2/#smart-if-tag)
> > with an earlier release of Django. You either need to stick to the if tag
> > syntax supported by your lower-level release or upgrade your Django install
> > to 1.2.
>
> > Karen
> > --http://tracey.org/kmt/--
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+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 23rd of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support