Removing 'None' from the print format for an empty field

Hello people, I am having problems removing ‘None’ from the print format if the value is absent. As an example. On a delivery note if the company name is missing in case the customer doesn’t have a company, the print displays something like:

None
Dave Braams
2 martins street
London, England

Instead, I want ‘None’ to be removed and just want:

Dave Braams
2 martins street
London, England

I tried writing a code for it, but it doesn’t seem to work



{% if doc.firma != ‘’ %}
{{ doc.firma }}

{% endif %}
{{ doc.customer_name }}

{{ doc.address_display }}

Kindly help me out.

2 Likes

You can use {{ doc.firma or '' }} to avoid printing None in the print, although this might leave an empty line.

Alternatively, you can also try the condition {% if doc.firma %} to check for truthy values, instead of an explicit value check.

Hope this helps!

2 Likes

Thanks a lot, it works and leaves no empty space.

For newbies like me wondering, this is the working code.

<br><div>
    {% if doc.firma %}
      {{ doc.firma }}<br>
    {% endif %}
</div>
5 Likes