Ticket #1742: db-api.patch

File db-api.patch, 3.3 KB (added by pb@…, 19 years ago)
  • docs/db-api.txt

     
    216216    lookup parameters.
    217217
    218218The lookup parameters (``**kwargs`` in the above function definitions) should
    219 be in the format described in _`Field lookups` below.
     219be in the format described in `Field lookups`_ below.
    220220
    221221For example, to get a ``QuerySet`` of blog entries from the year 2006, use
    222222``filter()`` like so::
     
    298298    * **len().** A ``QuerySet`` is evaluated when you call ``len()`` on it.
    299299      This, as you might expect, returns the length of the result list.
    300300
    301       Note: *Don't* use ``len()`` on ``QuerySet``s if all you want to do is
     301      Note: *Don't* use ``len()`` on a ``QuerySet`` if all you want to do is
    302302      determine the number of records in the set. It's much more efficient to
    303303      handle a count at the database level, using SQL's ``SELECT COUNT(*)``,
    304304      and Django provides a ``count()`` method for precisely this reason. See
     
    328328parameters.
    329329
    330330The lookup parameters (``**kwargs``) should be in the format described in
    331 _`Field lookups` below. Multiple parameters are joined via ``AND`` in the
     331`Field lookups`_ below. Multiple parameters are joined via ``AND`` in the
    332332underlying SQL statement.
    333333
    334334``exclude(**kwargs)``
     
    338338lookup parameters.
    339339
    340340The lookup parameters (``**kwargs``) should be in the format described in
    341 _`Field lookups` below. Multiple parameters are joined via ``AND`` in the
     341`Field lookups`_ below. Multiple parameters are joined via ``AND`` in the
    342342underlying SQL statement, and the whole thing is enclosed in a ``NOT()``.
    343343
    344344This example excludes all entries whose ``pub_date`` is the current date/time
     
    650650~~~~~~~~~~~~~~~~~
    651651
    652652Returns the object matching the given lookup parameters, which should be in
    653 the format described in _`Field lookups`.
     653the format described in `Field lookups`_.
    654654
    655655``get()`` raises ``AssertionError`` if more than one object was found.
    656656
     
    10701070``QuerySet`` reuse the cached results.
    10711071
    10721072Keep this caching behavior in mind, because it may bite you if you don't use
    1073 your ``QuerySet``s correctly. For example, the following will create two
    1074 ``QuerySet``s, evaluate them, and throw them away::
     1073your ``QuerySet`` objects correctly. For example, the following will create two
     1074``QuerySet`` objects, evaluate them, and throw them away::
    10751075
    10761076    print [e.headline for e in Entry.objects.all()]
    10771077    print [e.pub_date for e in Entry.objects.all()]
     
    13491349    >>> c = Choice(poll_id=p.id, choice="Over easy", votes=0)
    13501350    >>> c.save()
    13511351
    1352 Note that when using the `create()`` method, you do not give any value
     1352Note that when using the ``create()`` method, you do not give any value
    13531353for the ``id`` field, nor do you give a value for the field that stores
    13541354the relation (``poll_id`` in this case).
    13551355
     
    14201420``DoesNotExist`` exception when appropriate.
    14211421
    14221422Both methods accept optional keyword arguments, which should be in the format
    1423 described in _`Field lookups` above.
     1423described in `Field lookups`_ above.
    14241424
    14251425Note that in the case of identical date values, these methods will use the ID
    14261426as a fallback check. This guarantees that no records are skipped or duplicated.
Back to Top