The QuerySet value for an exact lookup must be limited to one result using slicing-Django

前端 未结 3 1997
星月不相逢
星月不相逢 2021-01-13 00:37

I\'m building a news website.While I tried to get the list of relative news which have the same tags.The error said:The QuerySet value for an exact lookup must be li

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 01:16

    I also experienced the same issue, try doing this, instead of:

    relative_news = News.objects.filter(tag=tags)

    to

    relative_news = News.objects.filter(tag=tags).first()

提交回复
热议问题