Django filter vs exclude
Posted
by Enrico
on Stack Overflow
See other posts from Stack Overflow
or by Enrico
Published on 2010-03-11T03:38:40Z
Indexed on
2010/03/11
17:34 UTC
Read the original article
Hit count: 530
Is there a difference between filter and exclude in django? If I have
self.get_query_set().filter(modelField=x)
and I want to add another criteria, is there a meaningful difference between to following two lines of code?
self.get_query_set().filter(user__isnull=False, modelField=x)
self.get_query_set().filter(modelField=x).exclude(user__isnull=True)
is one considered better practice or are they the same in both function and performance?
© Stack Overflow or respective owner