Thursday, March 29, 2012

Re: comparing custom template tag within if tag

I think something like this would work:
{% with price_for_pax service pax '' as pfp %}
{% if service.price == pfp %}
do something
{% endif %}
{% endwith %}

Alternatively if price_for_pax is only used for comparing to
service.price you could have it return true or false based on whether
whatever equaled service.price, and then use it more directly.

Regards,
Josh

On Mar 29, 1:54 am, Tom Evans <tevans...@googlemail.com> wrote:
> On Wed, Mar 28, 2012 at 4:59 PM, Nikhil Verma <varma.nikhi...@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/#se...
>
> 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