{% for vul3 in vul["ports_data"] %}
<td>{{ vul3["vulnerabilities"]["vulners"] }}</td>
{% endfor %}
Im getting a lot of empty values from the output which is filling my table with empty results, Anyway to get rid of it? I only wanna show the values which exist.
CodePudding user response:
Test the trimmed length of your field to exclude empty cells.
You can also test for None simply doing if vul3.vulnerabilities.vulners.
Those two together:
{% for vul3 in vul.ports_data %}
{% if vul3.vulnerabilities.vulners
and vul3.vulnerabilities.vulners | trim | length
%}
<tr>
<td>{{ vul3.vulnerabilities.vulners }}</td>
<tr>
{% endif %}
{% endfor %}
CodePudding user response:
So this would be the answer, It cuts out all the empty values
{% for vul3 in vul.ports_data %}
{% if vul3.vulnerabilities.vulners
and vul3.vulnerabilities.vulners | trim | length
%}
<tr>
<td>{{ vul3.vulnerabilities.vulners }}</td>
<tr>
{% endif %}
{% endfor %}
