{% 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)
1条答案
按热度按时间eagi6jfj1#
它只应该是: