From 21acccbca25948ba04be05a5d2750d88ffa2fa37 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Thu, 7 Jun 2007 18:24:27 +0000 Subject: [PATCH] Fixed #4214: added a bit of explicit info on updating FK fields to db-api.txt. Thanks, david@kazserve.org. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5437 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/db-api.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/db-api.txt b/docs/db-api.txt index dda3377885..8c93cb78d4 100644 --- a/docs/db-api.txt +++ b/docs/db-api.txt @@ -134,6 +134,15 @@ the database until you explicitly call ``save()``. The ``save()`` method has no return value. +Updating ``ForeignKey`` fields works exactly the same way; simply assign an +object of the right type to the field in question:: + + joe = Author.objects.create(name="Joe") + entry.author = joe + entry.save() + +Django will complain if you try to assign an object of the wrong type. + How Django knows to UPDATE vs. INSERT -------------------------------------