Ticket #5068: 5068.patch

File 5068.patch, 833 bytes (added by Collin Grady <cgrady@…>, 8 years ago)
  • docs/db-api.txt

     
    207207
    208208The ``save()`` method has no return value.
    209209
    210 Updating ``ForeignKey`` fields works exactly the same way; simply assign an
    211 object of the right type to the field in question::
     210Updating a ``ManyToManyField`` works a little different; use the ``add()``
     211method on the field to add a record to the relation::
    212212
    213213    joe = Author.objects.create(name="Joe")
    214     entry.author = joe
    215     entry.save()
     214    entry.authors.add(joe)
    216215
    217 Django will complain if you try to assign an object of the wrong type.
     216Django will complain if you try to add an object of the wrong type.
    218217
    219218How Django knows to UPDATE vs. INSERT
    220219-------------------------------------
Back to Top