added documentation for the query kwargs introduced by [1534]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1536 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Georg Bauer 2005-12-04 14:04:56 +00:00
parent 7dbff908b5
commit 4ed3d57184
1 changed files with 45 additions and 39 deletions

View File

@ -152,45 +152,51 @@ translates (roughly) into the following SQL::
The DB API supports the following lookup types: The DB API supports the following lookup types:
=========== ============================================================== ============= ==============================================================
Type Description Type Description
=========== ============================================================== ============= ==============================================================
exact Exact match: ``polls.get_object(id__exact=14)``. exact Exact match: ``polls.get_object(id__exact=14)``.
iexact Case-insensitive exact match: iexact Case-insensitive exact match:
``polls.get_list(slug__iexact="foo")`` matches a slug of ``polls.get_list(slug__iexact="foo")`` matches a slug of
``foo``, ``FOO``, ``fOo``, etc. ``foo``, ``FOO``, ``fOo``, etc.
contains Case-sensitive containment test: contains Case-sensitive containment test:
``polls.get_list(question__contains="spam")`` returns all polls ``polls.get_list(question__contains="spam")`` returns all polls
that contain "spam" in the question. (PostgreSQL and MySQL that contain "spam" in the question. (PostgreSQL and MySQL
only. SQLite doesn't support case-sensitive LIKE statements; only. SQLite doesn't support case-sensitive LIKE statements;
``contains`` will act like ``icontains`` for SQLite.) ``contains`` will act like ``icontains`` for SQLite.)
icontains Case-insensitive containment test. notcontains negated ``contains``
gt Greater than: ``polls.get_list(id__gt=4)``. icontains Case-insensitive containment test.
gte Greater than or equal to. inotcontains negated ``icontains``
lt Less than. gt Greater than: ``polls.get_list(id__gt=4)``.
lte Less than or equal to. gte Greater than or equal to.
ne Not equal to. lt Less than.
in In a given list: ``polls.get_list(id__in=[1, 3, 4])`` returns lte Less than or equal to.
a list of polls whose IDs are either 1, 3 or 4. ne Not equal to.
startswith Case-sensitive starts-with: in In a given list: ``polls.get_list(id__in=[1, 3, 4])`` returns
``polls.get_list(question_startswith="Would")``. (PostgreSQL a list of polls whose IDs are either 1, 3 or 4.
and MySQL only. SQLite doesn't support case-sensitive LIKE startswith Case-sensitive starts-with:
statements; ``startswith`` will act like ``istartswith`` for ``polls.get_list(question_startswith="Would")``. (PostgreSQL
SQLite.) and MySQL only. SQLite doesn't support case-sensitive LIKE
endswith Case-sensitive ends-with. (PostgreSQL and MySQL only.) statements; ``startswith`` will act like ``istartswith`` for
istartswith Case-insensitive starts-with. SQLite.)
iendswith Case-insensitive ends-with. notstartswith negated ``startswith``
range Range test: endswith Case-sensitive ends-with. (PostgreSQL and MySQL only.)
``polls.get_list(pub_date__range=(start_date, end_date))`` notendswith negated ``endswith``
returns all polls with a pub_date between ``start_date`` istartswith Case-insensitive starts-with.
and ``end_date`` (inclusive). inotstartswith negated ``istartswith``
year For date/datetime fields, exact year match: iendswith Case-insensitive ends-with.
``polls.get_count(pub_date__year=2005)``. inotendswith negated ``iendswith``
month For date/datetime fields, exact month match. range Range test:
day For date/datetime fields, exact day match. ``polls.get_list(pub_date__range=(start_date, end_date))``
isnull True/False; does is IF NULL/IF NOT NULL lookup: returns all polls with a pub_date between ``start_date``
``polls.get_list(expire_date__isnull=True)``. and ``end_date`` (inclusive).
=========== ============================================================== year For date/datetime fields, exact year match:
``polls.get_count(pub_date__year=2005)``.
month For date/datetime fields, exact month match.
day For date/datetime fields, exact day match.
isnull True/False; does is IF NULL/IF NOT NULL lookup:
``polls.get_list(expire_date__isnull=True)``.
============= ==============================================================
Multiple lookups are allowed, of course, and are translated as "AND"s:: Multiple lookups are allowed, of course, and are translated as "AND"s::