diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-06-18 13:32:48 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-06-18 13:32:48 +0000 |
| commit | 3db96017bac70bd53697f5fe5e37362707f7490d (patch) | |
| tree | 7f2480880789dcc195ef3aaa93ae509b9b3b6c09 /docs | |
| parent | 457a1f9a031543e3d5d1cfb3944712fe71ebba2f (diff) | |
Fixed #11278 -- Clarified query documentation regarding bulk assignment of m2m values. Thanks to zgoda for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11045 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/db/queries.txt | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt index 4aa54261c4..34a8b7943a 100644 --- a/docs/topics/db/queries.txt +++ b/docs/topics/db/queries.txt @@ -278,7 +278,7 @@ For example, this returns the first 5 objects (``LIMIT 5``):: This returns the sixth through tenth objects (``OFFSET 5 LIMIT 5``):: >>> Entry.objects.all()[5:10] - + Negative indexing (i.e. ``Entry.objects.all()[-1]``) is not supported. Generally, slicing a ``QuerySet`` returns a new ``QuerySet`` -- it doesn't @@ -945,11 +945,17 @@ in the :ref:`related objects reference <ref-models-relations>`. Removes all objects from the related object set. To assign the members of a related set in one fell swoop, just assign to it -from any iterable object. Example:: +from any iterable object. The iterable can contain object instances, or just +a list of primary key values. For Example:: + +Example:: b = Blog.objects.get(id=1) b.entry_set = [e1, e2] +In this example, ``e1`` and ``e2`` can be full Entry instances, or integer +values representing primary keys. + If the ``clear()`` method is available, any pre-existing objects will be removed from the ``entry_set`` before all objects in the iterable (in this case, a list) are added to the set. If the ``clear()`` method is *not* |
