回答:
None, False and Trueすべてはテンプレートタグとフィルター内で使用できます。None, False、空の文字列('', "", """""")および空のリスト/タプルはすべて、Falseによって評価されるときに評価されるifため、簡単に行うことができます
{% if profile.user.first_name == None %}
{% if not profile.user.first_name %}
ヒント:@fabiocerqueiraは正しいです。ロジックをモデルに任せ、テンプレートを唯一のプレゼンテーションレイヤーに制限して、モデルのようなものを計算します。例:
# someapp/models.py
class UserProfile(models.Model):
    user = models.OneToOneField('auth.User')
    # other fields
    def get_full_name(self):
        if not self.user.first_name:
            return
        return ' '.join([self.user.first_name, self.user.last_name])
# template
{{ user.get_profile.get_full_name }}
お役に立てれば :)
{% if profile.user.first_name is None %}Djangoテンプレートで構文エラーが発生します。
                    default_if_none、テンプレートでフィルターを使用するのはどうでしょうか。
                    別の組み込みテンプレートを使用することもできます default_if_none
{{ profile.user.first_name|default_if_none:"--" }}
              date最初に適用します。エラーが発生した場合はNoneを返します。次に、適用しますdefault_if_none。
                    isoperator:Django 1.10の新機能
{% if somevar is None %}
  This appears if somevar is None, or if somevar is not found in the context.
{% endif %}
              組み込みのテンプレートフィルターを使用することもできますdefault。
値がFalseと評価された場合(例:なし、空の文字列、0、False); デフォルトの「-」が表示されます。
{{ profile.user.first_name|default:"--" }}
ドキュメント:https : //docs.djangoproject.com/en/dev/ref/templates/builtins/#default
あなたはこれを試すことができます:
{% if not profile.user.first_name.value %}
  <p> -- </p>
{% else %}
  {{ profile.user.first_name }} {{ profile.user.last_name }}
{% endif %}
この方法では、フォームフィールドfirst_nameに関連付けられた値があるかどうかを本質的にチェックしています。Django Documentationのフォームのフィールドをループするを参照{{ field.value }}してください。
Django 3.0を使用しています。