mirror of
https://github.com/django/django.git
synced 2024-11-29 22:56:46 +01:00
Minor edits to docs/topics/db/queries.txt.
This commit is contained in:
parent
848101bf17
commit
8bfc7cc64c
@ -140,8 +140,8 @@ To retrieve objects from your database, construct a
|
|||||||
:class:`~django.db.models.Manager` on your model class.
|
:class:`~django.db.models.Manager` on your model class.
|
||||||
|
|
||||||
A :class:`~django.db.models.query.QuerySet` represents a collection of objects
|
A :class:`~django.db.models.query.QuerySet` represents a collection of objects
|
||||||
from your database. It can have zero, one or many *filters* -- criteria that
|
from your database. It can have zero, one or many *filters*. Filters narrow
|
||||||
narrow down the collection based on given parameters. In SQL terms, a
|
down the query results based on the given parameters. In SQL terms, a
|
||||||
:class:`~django.db.models.query.QuerySet` equates to a ``SELECT`` statement,
|
:class:`~django.db.models.query.QuerySet` equates to a ``SELECT`` statement,
|
||||||
and a filter is a limiting clause such as ``WHERE`` or ``LIMIT``.
|
and a filter is a limiting clause such as ``WHERE`` or ``LIMIT``.
|
||||||
|
|
||||||
@ -257,10 +257,10 @@ Example::
|
|||||||
These three ``QuerySets`` are separate. The first is a base
|
These three ``QuerySets`` are separate. The first is a base
|
||||||
:class:`~django.db.models.query.QuerySet` containing all entries that contain a
|
:class:`~django.db.models.query.QuerySet` containing all entries that contain a
|
||||||
headline starting with "What". The second is a subset of the first, with an
|
headline starting with "What". The second is a subset of the first, with an
|
||||||
additional criteria that excludes records whose ``pub_date`` is greater than
|
additional criteria that excludes records whose ``pub_date`` is today or in the
|
||||||
now. The third is a subset of the first, with an additional criteria that
|
future. The third is a subset of the first, with an additional criteria that
|
||||||
selects only the records whose ``pub_date`` is greater than now. The initial
|
selects only the records whose ``pub_date`` is today or in the future. The
|
||||||
:class:`~django.db.models.query.QuerySet` (``q1``) is unaffected by the
|
initial :class:`~django.db.models.query.QuerySet` (``q1``) is unaffected by the
|
||||||
refinement process.
|
refinement process.
|
||||||
|
|
||||||
.. _querysets-are-lazy:
|
.. _querysets-are-lazy:
|
||||||
@ -1079,8 +1079,9 @@ the foreign key aren't saved to the database until you call
|
|||||||
>>> e.blog = some_blog
|
>>> e.blog = some_blog
|
||||||
>>> e.save()
|
>>> e.save()
|
||||||
|
|
||||||
If a :class:`~django.db.models.ForeignKey` field has ``null=True`` set (i.e., it allows ``NULL``
|
If a :class:`~django.db.models.ForeignKey` field has ``null=True`` set (i.e.,
|
||||||
values), you can assign ``None`` to it. Example::
|
it allows ``NULL`` values), you can assign ``None`` to remove the relation.
|
||||||
|
Example::
|
||||||
|
|
||||||
>>> e = Entry.objects.get(id=2)
|
>>> e = Entry.objects.get(id=2)
|
||||||
>>> e.blog = None
|
>>> e.blog = None
|
||||||
|
Loading…
Reference in New Issue
Block a user