Ticket #5267: Fix5267.diff
File Fix5267.diff, 1.0 KB (added by , 17 years ago) |
---|
-
docs/db-api.txt
211 211 -------------------------------------------- 212 212 213 213 Updating ``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:: 214 field; simply assign an object of the right type to the field in question:: 215 215 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() 219 219 220 220 Updating a ``ManyToManyField`` works a little differently; use the ``add()`` 221 221 method on the field to add a record to the relation:: … … 511 511 512 512 Entry.objects.order_by('?') 513 513 514 Note: ``order_by('?')`` queries may be expensive and slow, depending on the 515 database used. 516 514 517 To order by a field in a different table, add the other table's name and a dot, 515 518 like so:: 516 519