2

How is exact lookup diffferent from equal lookup in Django

I have two queries

Blog.objects.get(title=title)

Blog.objects.get(title__exact=title)

What is the difference between these two?

4

2 回答 2

2

没有区别,第一个和第二个完全一样。

查看文档

Blog.objects.get(id__exact=14)  # Explicit form
Blog.objects.get(id=14)         # __exact is implied
于 2013-05-21T09:12:02.467 回答
2

exact是默认值。检查django 文档

如果您不提供查找类型(即,如果您的关键字参数不包含双下划线),则假定查找类型为exact.

于 2013-05-21T09:16:42.427 回答