2
私はContentTypeフィールドを持つモデルを持っています。いずれのモデル法ではdjangoのコンテンツタイプと文字列の比較
私は文字列にそれを比較することができます
self.content_type == "construction" # True if ContentObject points to Construction model.
しかし、そのようなことは、テンプレートで動作するようには思えません。
私は
{% if object.content_type == "construction" %}
秒をしようとした最初のもの:
def __unicode__(self):
return str(self.content_type)
`{% if object == "construction" %}`
、それは偽ですが、{{オブジェクト}}がconstruction
を印刷します。
試してみてください。{%if object.content_type.model == "construction"%} ' –