Author: russellm Date: 2009-06-18 08:32:48 -0500 (Thu, 18 Jun 2009) New Revision: 11045
Modified: django/trunk/docs/topics/db/queries.txt Log: Fixed #11278 -- Clarified query documentation regarding bulk assignment of m2m values. Thanks to zgoda for the patch. Modified: django/trunk/docs/topics/db/queries.txt =================================================================== --- django/trunk/docs/topics/db/queries.txt 2009-06-18 13:32:12 UTC (rev 11044) +++ django/trunk/docs/topics/db/queries.txt 2009-06-18 13:32:48 UTC (rev 11045) @@ -278,7 +278,7 @@ 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 @@ 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* --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---