在 Django 过滤器语句中,__exact 和等号 (=) 之间有什么区别? [英] In Django filter statement what's the difference between __exact and equal sign (=)?

查看:36
本文介绍了在 Django 过滤器语句中,__exact 和等号 (=) 之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Django 过滤语句中,如果我写有什么不同:

In Django filter statement what's the difference if I write:

.filter(name__exact='Alex')

.filter(name='Alex')

谢谢

推荐答案

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

There is no difference, the second one implies using the __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.

这篇关于在 Django 过滤器语句中,__exact 和等号 (=) 之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆