Wednesday, February 28, 2018

Re: django mathfiters

Thanks Peter.

cheers,

On Wed, Feb 28, 2018 at 5:05 PM, Peter of the Norse <RahmCoff@radio1190.org> wrote:
I would do
{% with a=42 c=b.value|default_if_none:0}

- Peter of the Norse

On Feb 21, 2018, at 3:47 PM, Matthew Pava <Matthew.Pava@iss.com> wrote:

And how are you checking if it's None?  I would do it like this:

{% if c %}

    {{ a|add:c }}

{% else %}

  {{ a }}

{% endif %}

 

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of sum abiut
Sent: Wednesday, February 21, 2018 4:43 PM
To: django-users@googlegroups.com
Subject: Re: django mathfiters

 

Thanks for your response. Yes the value was actually None. how to i display 42  instead of not displaying anything at all. I have try using the if statement to check for the value of c if its None i just display the value of a, and if is not None i add the values. But still its displaying nothing.

 

Thanks

 

On Thu, Feb 22, 2018 at 9:15 AM, Matthew Pava <Matthew.Pava@iss.com> wrote:

Check the value of b.value.  Make sure it isn't None.

 

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of sum abiut
Sent: Wednesday, February 21, 2018 4:06 PM
To: django-users@googlegroups.com
Subject: django mathfiters

 

 

Hi,

How to you a zero in mathfilter

for example, if the value of c is zero the total is not display. instead of displaying 42 it display nothing.

 

{%for b in pay%}

{% with a=42 c=b.value%}
    <li> {{ a|add:c }}</li>
    {% endwith %}


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8C4DDEF6-9168-4181-B5DD-8E37AB487685%40Radio1190.org.

For more options, visit https://groups.google.com/d/optout.



--

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y763dna8pOwE0d-9ZRZvhxHqMdBxV1TPEU0gmMGmicQ0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment