Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Django filter statement what's the difference between __exact and equal sign (=)?

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

.filter(name__exact='Alex') 

and

.filter(name='Alex') 

Thanks

like image 579
Alex Avatar asked Apr 01 '12 09:04

Alex


1 Answers

There is no difference, the second one implies using the __exact.

From the 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. 
like image 73
MikeAr Avatar answered Oct 02 '22 21:10

MikeAr