Django怎么判断两个实例的字段内容一致

在学习Django的时候,我要做一个展示页面,发现不能通过 == 来判断两个实例其中一个字段的内容一致。以下代码不报错,但是html文件的==判断所有值不相等。
models.py
class Goods_of_type(models.Model):
goods_of_type=models.CharField(max_length=20)
def str(self):
return self.goods_of_type
class Good(models.Model):
goods_of_type=models.ForeignKey(Goods_of_type,on_delete=models.CASCADE)
name=models.CharField(max_length=50)
date_added=models.DateTimeField(auto_now_add=True)
describe_of_good=models.TextField()
class Meta:
verbose_name_plural='good'
def str(self):
return self.name

views.py

def goods(request):
goods=Goods_of_type.objects.order_by()
good=Good.objects.order_by()
context={'goods':goods,"good":good}
return render(request,'goods/goods.html',context)

goods.html

{% extends 'goods/base.html' %}
{% block content %}

river的商场具有如下品类


{% for line in goods %}

  • {{ line }}

  • {# {{ line.goods_of_type }}#} {% for linex in good %} {% if line.goods_of_type == linex.goods_of_type %} {{ linex.goods_of_type }} {% endif %} {% endfor %} {% endfor %} {% endblock content %}
不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^