change {% if establishment.property_id != 0 %} to {% if establishment.property_id %}. This approach is not unique to the template, if you were doing it in the backend code, I would be saying the same thing. In python 0 and None both evaluate to False and you do not check if something == None, you only say if something.