Ticket #4214: db-api.patch
File db-api.patch, 749 bytes (added by , 18 years ago) |
---|
-
db-api.txt
134 134 135 135 The ``save()`` method has no return value. 136 136 137 How to update a Foreign Key field 138 --------------------------------- 139 140 To update a foreign key field, assign a compatible database object to the field. 141 142 Given a models.py contained this definition 143 144 class Blog(models.Model): 145 ... 146 owner = models.ForeignKey('Owner') 147 148 This example would update ``Blog`` instance ``b5`` to point to "Jill" as the owner for the blog:: 149 150 p = Owner.objects.create(name="Jill") 151 b5.owner = p 152 b5.save() 153 137 154 How Django knows to UPDATE vs. INSERT 138 155 ------------------------------------- 139 156