如何在查询中进行过滤,以便结果排除列表中的一个对象?当 id=1 模型 = AutoShow
看法:
class autoshow_index(ListView):
context_object_name = "numcar"
model = AutoShow
def get_context_data(self, **kwargs):
context = super(autoshow_index, self).get_context_data(**kwargs)
context['bnrlarg'] = BannerLarge.objects.all()[:1]
return context
模板 :
{% for autoshow in object_list %}
<h2><a href="/autoshow_page/{{autoshow.slug}}"> {{ autoshow.title }}</a></h2>
{% endfor %}