这是查询集:
researches = Graph.objects.filter(subject=subject_object).exclude(type='infografik').values_list('name', flat=True).distinct()
当我做:
{% for research in researches %}
在我的模板中,中间的代码执行了正确的次数,但例如{{ research.name }}
不起作用。
如何访问对象的属性?
谢谢。
编辑:
图模型
name = models.CharField(max_length=100)
research = models.ForeignKey('Research')
explanation = models.TextField(max_length=1000)
path_to_file = models.CharField(max_length=100)
type = models.CharField(max_length=30, choices=type, null=True, blank=True)
subject = models.ManyToManyField(Subject)
thumbnail = models.ImageField(upload_to='thumbnails/', null=True, blank=True)
slug = models.SlugField(max_length=120, unique=True)