What is the equivalent of “none” in django templates?

后端 未结 7 938
孤街浪徒
孤街浪徒 2020-12-12 21:40

I want to see if a field/variable is none within a Django template. What is the correct syntax for that?

This is what I currently have:

{% if profile         


        
相关标签:
7条回答
  • 2020-12-12 22:12

    {% if profile.user.first_name %} works (assuming you also don't want to accept '').

    if in Python in general treats None, False, '', [], {}, ... all as false.

    0 讨论(0)
提交回复
热议问题