Thursday, March 29, 2012

Re: comparing custom template tag within if tag

On Wed, Mar 28, 2012 at 4:59 PM, Nikhil Verma <varma.nikhil22@gmail.com> wrote:
> Hi all
>
> i have a custom template tag that takes some argument and calculates the
> result.
> I want to compare that value obtained from that custom tag with another
> variable.
>
> Custom template tag
> {% price_for_pax service pax '' %}
>
> variable :
>
> {{service.price}}
>
> What i want is {% if service.price == price_for_pax service pax ' ' %}
>                        do something
>                      {% endif %}
>
> When i look for the result it does not show anything
> Can i compare like this ? If not what can be the solution ?
>
> Thanks in advance
>

The manual has a section on this:

https://docs.djangoproject.com/en/1.4//howto/custom-template-tags/#setting-a-variable-in-the-context

Cheers

Tom

--
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