gpt4 book ai didi

django - 在Django过滤器语句中,__exact和等号(=)有什么区别?

转载 作者:行者123 更新时间:2023-12-03 11:35:20 26 4
gpt4 key购买 nike

在Django过滤器语句中,如果我写,有什么区别:

.filter(name__exact='Alex')


.filter(name='Alex')

谢谢

最佳答案

没有区别,第二个暗示使用__exact。

documentation:

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.

关于django - 在Django过滤器语句中,__exact和等号(=)有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9963200/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com