在Django 过滤声明中,如果我写道:
.filter(name__exact='Alex')
和
.filter(name='Alex')
谢谢
在Django 过滤声明中,如果我写道:
.filter(name__exact='Alex')
和
.filter(name='Alex')
谢谢
没有区别,第二个意思是使用__exact.
For example, the following two statements are equivalent:
>>> Blog.objects.get(id__exact=14) # Explicit form
>>> Blog.objects.get(id=14)
# __exact is implied This is for convenience, because exact
# lookups are the common case.