-1

結果が list 内の 1 つのオブジェクトを除外するようにクエリをフィルター処理するにはどうすればよいですか? 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 %}  
4

1 に答える 1

2

これをautoshow_indexクラスに含めます

def get_queryset(self):
    return AutoShow.objects.exclude(id=1)
于 2013-03-02T19:58:01.083 に答える