Code

Ticket #12338: django-models-doc.diff

File django-models-doc.diff, 1.3 KB (added by blueyed, 5 years ago)

Patch against trunk

Line 
1Index: docs/topics/db/models.txt
2===================================================================
3--- docs/topics/db/models.txt   (Revision 11798)
4+++ docs/topics/db/models.txt   (Arbeitskopie)
5@@ -726,9 +726,9 @@
6         name = models.CharField(max_length=100)
7         tagline = models.TextField()
8 
9-        def save(self, force_insert=False, force_update=False):
10+        def save(self, *args, **kwargs):
11             do_something()
12-            super(Blog, self).save(force_insert, force_update) # Call the "real" save() method.
13+            super(Blog, self).save(*args, **kwargs) # Call the "real" save() method.
14             do_something_else()
15 
16 You can also prevent saving::
17@@ -737,11 +737,11 @@
18         name = models.CharField(max_length=100)
19         tagline = models.TextField()
20 
21-        def save(self, force_insert=False, force_update=False):
22+        def save(self, *args, **kwargs):
23             if self.name == "Yoko Ono's blog":
24                 return # Yoko shall never have her own blog!
25             else:
26-                super(Blog, self).save(force_insert, force_update) # Call the "real" save() method.
27+                super(Blog, self).save(*args, **kwargs) # Call the "real" save() method.
28 
29 It's important to remember to call the superclass method -- that's that
30 ``super(Blog, self).save()`` business -- to ensure that the object still gets