I have a model with ContentType field in it.
In any model method I can compare it to the string:
self.content_type == "construction" # True if ContentObject points to Construction model.
However, such thing doesn’t seem to work in templates.
First thing I tried
{% if object.content_type == "construction" %}
And second:
def __unicode__(self):
return str(self.content_type)
`{% if object == "construction" %}`
and it’s False, but {{ object }} prints construction.
The unicode method for
ContentTypesimply displays the name, which is why{{ object }}displaysconstructionin the template.However,
object.content_typeis aContentTypeinstance, not a string, so comparing it to “construction” will always returnFalse. Try comparing the content type’smodelinstead.