'<hr> showing even if its in IF condition in django Template

I want a horizontal ruler after every tag but only when the tag is available. I placed the hr tag inside the IF condition in Django Template engine but hr shows no matter if condition is true or not.

code ->

          {% if i.Tag2 is not none %}
            <hr>
            {{i.Tag2_Name}}
          {% endif %}
          {% if i.Tag3 is not none %}
            <hr>
            {{i.Tag3_Name}}
          {% endif %}

Example 1 where condition is True

Example 1 -> where condition is True

enter image description here

Example 2 -> where condition is False but still it shows a ruler

Unable to figure out the reason.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source