django {% if {club.c_type} == 'Tech' %}出现错误代码在没有该错误的情况下也能正常工作,要根据同一页面中的基础或Tech和Non Tech筛选数据吗

6vl6ewon  于 2023-03-04  发布在  Go
关注(0)|答案(1)|浏览(72)
{% for club in clubs %}
{% if {club.c_type} == 'Tech' %}
SOME CODE  
{% endif %}
{% endfor %}
def clubs(request):
    clubs_data = Clubs.objects.all()
    return render(request, 'clubs.html', {'clubs': clubs_data})

CLUBS_TYPE = {('T', 'Tech'), ('NT', 'Non-Tech')}

class Clubs(models.Model):
    club_id = models.CharField(primary_key=True, max_length=5)
    c_name = models.CharField(max_length=50)
    c_logo = models.ImageField(upload_to='clubimg')
    c_type = models.CharField(choices=CLUBS_TYPE, max_length=2)
eagi6jfj

eagi6jfj1#

它只应该是:

{% if club.c_type == 'Tech' %}
SOME CODE  
{% endif %}

相关问题