Ticket #5267: Fix5267.diff

File Fix5267.diff, 1.0 KB (added by Matt Boersma, 17 years ago)

Added a warning sentence that order_by('?') may be expensive and slow

  • docs/db-api.txt

     
    211211--------------------------------------------
    212212
    213213Updating ``ForeignKey`` fields works exactly the same way as saving a normal
    214 field; simply assign an object of the right type to the field in question:: 
     214field; simply assign an object of the right type to the field in question::
    215215
    216     cheese_blog = Blog.objects.get(name="Cheddar Talk") 
    217     entry.blog = cheese_blog 
    218     entry.save() 
     216    cheese_blog = Blog.objects.get(name="Cheddar Talk")
     217    entry.blog = cheese_blog
     218    entry.save()
    219219
    220220Updating a ``ManyToManyField`` works a little differently; use the ``add()``
    221221method on the field to add a record to the relation::
     
    511511
    512512    Entry.objects.order_by('?')
    513513
     514Note: ``order_by('?')`` queries may be expensive and slow, depending on the
     515database used.
     516
    514517To order by a field in a different table, add the other table's name and a dot,
    515518like so::
    516519
Back to Top