擅长:python、mysql、java
<p>查询中的<code>field=value</code>语法是<code>field__exact=value</code>的简写。也就是说<a href="http://docs.djangoproject.com/en/dev/ref/models/querysets/#field-lookups" rel="noreferrer">Django puts query operators on query fields in the identifiers</a>。Django支持以下运算符:</p>
<pre><code>exact
iexact
contains
icontains
in
gt
gte
lt
lte
startswith
istartswith
endswith
iendswith
range
year
month
day
week_day
isnull
search
regex
iregex
</code></pre>
<p>我确信,通过将它们与Q对象组合成<a href="https://stackoverflow.com/questions/687295/how-do-i-do-a-not-equal-in-django-queryset-filtering/1154977#1154977">Dave Vogt suggests</a>,并使用<code>filter()</code>或<code>exclude()</code>作为<a href="https://stackoverflow.com/questions/687295/how-do-i-do-a-not-equal-in-django-queryset-filtering/687316#687316">Jason Baker suggests</a>,您将得到您所需要的任何可能的查询。</p>