Django check for any exists for a query

前端 未结 3 1025
梦如初夏
梦如初夏 2021-02-01 00:12

In django how to check whether any entry exists for a query

sc=scorm.objects.filter(Header__id=qp.id)

This was how it was done in php

3条回答
  •  旧时难觅i
    2021-02-01 00:31

    this worked for me!

    if some_queryset.objects.all().exists(): print("this table is not empty")

提交回复
热议问题