Diango 数据库操作API:
| 类型 | 描述 |
|---|---|
| exact | 精确匹配: polls.get_object(id__exact=14). |
| iexact | 忽略大小写的精确匹配: polls.objects.filter(slug__iexact="foo") 匹配 foo, FOO, fOo, 等等. |
| contains | 大小写敏感的内容包含测试: polls.objects.filter(question__contains="spam") 返回question 中包含 "spam" 的所有民意测验.(仅PostgreSQL 和 MySQL支持. SQLite 的LIKE 语句不支持大小写敏感特性. 对Sqlite 来说, contains 等于 icontains.) |
| icontains | 大小写不敏感的内容包含测试: |
| gt | 大于: polls.objects.filter(id__gt=4). |
| gte | 大于等于. |
| lt | 小于. |
| lte | 小于等于. |
| ne | 不等于. |
| in | 位于给定列表中: polls.objects.filter(id__in=[1, 3, 4]) 返回一个 polls 列表(ID 值分别是 1或3或4). |
| startswith | 大小写敏感的 starts-with: polls.objects.filter(question__startswith="Would"). (仅PostgreSQL 和MySQL支持. SQLite 的LIKE 语句不支持大小写敏感特性. 对Sqlite 来说,``startswith`` 等于 istartswith) |
| endswith | 大小写敏感的 ends-with. (仅PostgreSQL 和 MySQL) |
| istartswith | 大小写不敏感的 starts-with. |
| iendswith | 大小写不敏感的 ends-with. |
| range | 范围测试: polls.objects.filter(pub_date__range=(start_date, end_date)) 返回 pub_date 位于 start_date 和 end_date (包括)之间的所有民意测验 |
| year | 对 date/datetime 字段, 进行精确的 年 匹配: polls.get_count(pub_date__year=2005). |
| month | 对 date/datetime 字段, 进行精确的 月 匹配: |
| day | 对 date/datetime 字段, 进行精确的 日 匹配: |
| isnull | True/False; 做 IF NULL/IF NOT NULL 查询: polls.objects.filter(expire_date__isnull=True). |
原文:http://www.cnblogs.com/cocoa-z/p/6903786.html