Python 无法比较django模板中的变量

Python 无法比较django模板中的变量,python,django,django-templates,Python,Django,Django Templates,我的模板代码: <select name="channelChoice" id="channelChoice" class="choiceBox"> <option value="0">Chose your channel</option> {% if channels %} {% for ch in channels %} {% if ch.id == default_channel_id %}

我的模板代码:

    <select name="channelChoice" id="channelChoice" class="choiceBox">
    <option value="0">Chose your channel</option>
    {% if channels %}
        {% for ch in channels %}
            {% if ch.id == default_channel_id %}
                <option class="channel-choice" value="{{ ch.id }}"  selected="selected" >{{ ch.title }}</option>
            {% else %}
                <option class="channel-choice" value="{{ ch.id }}" >{{ ch.title }}</option>
            {% endif %}
        {% endfor %}
    {% endif %}
</select>

我传递了值为1的默认\u通道\u id,并且通道列表包含一个id为1的通道。但若条款从未达成

查询中不需要
模型

from models import Channel
channels = Channel.objects.filter(activated=True).order_by('title')

您传递给模板的变量中有一个输入错误:default\u channle\u id

您能解释更多吗?我不知道您为什么要这样使用
model
。您没有导入它吗?请检查此项。您可以在视图中打印您的
频道
和您的
默认频道id
,以查看是否需要。此
模型
是一个包含从
django.db.models
扩展而来的我的
模型
列表的文件。我在文件顶部导入了它。打字错误是什么意思?你是说类型吗?你需要
default\u channel\u id
,但你通过了
default\u channel\u id
。这是一个拼写错误,意味着拼写错误。请更正此行中默认通道id的拼写:“return render(请求,'epgadmin/index.html',{'channels':channels,'default\channle\u id':default\u channel\u id})”。
from models import Channel
channels = Channel.objects.filter(activated=True).order_by('title')