0

Django を使用していますが、django.db.models の Q オブジェクトと count() を使用してクエリを使用するにはどうすればよいですか?

4

1 に答える 1

0

Given using a filter will result in a queryset object, you should just be able to use count() on the end of said containing filter. Like:

count = MyModel.objects.filter(Q(my_field__startswith='Hello')).count()
于 2012-09-24T17:32:20.320 に答える