Fill matrix with ZERO in null spaces, (python/Django)

Asked

Viewed 122 times

1

The problem is in the parts marked on red, I’m having trouble assigning zeroes to her. According to model:

inserir a descrição da imagem aqui

The excerpt of the code I am generating this table:

inserir a descrição da imagem aqui

*Obs: The selection of this period may vary according to the selection: (e.g. 2016 until 2017/ 2015 until 2017...)

  • 1

    It is more difficult to verify your problem when placing code as image. Could you edit your question by pasting the JS code? (This can be done by clicking on the paper image with <> next to insert image)

1 answer

0

If the variables somatorio.3 and somatorio.2 are presenting the value None, you can use the filter default_if_none to translate them to zero.

In your case it would look like this:

<td class="text-center">{{ somatorio.3|default_if_none:"0" }}({{ somatorio.2|default_if_none:"0" }})</td>
  • Guy tried here and not roll with default_if_none:"0". It follows equal.

  • Surely the reason is that somatorio.3 and somatorio.2 do not possess the value None, that is, are not null values as you put in your question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.