Ticket #8679: 8679.docs-tests-save.diff
File 8679.docs-tests-save.diff, 4.1 KB (added by , 16 years ago) |
---|
-
django/django/tests/modeltests/save_delete_hooks/models.py
16 16 17 17 def save(self, force_insert=False, force_update=False): 18 18 print "Before save" 19 19 # Call the "real" save() method 20 20 super(Person, self).save(force_insert, force_update) 21 21 print "After save" 22 22 -
django/django/tests/modeltests/model_forms/models.py
51 51 categories = models.ManyToManyField(Category, blank=True) 52 52 status = models.IntegerField(choices=ARTICLE_STATUS, blank=True, null=True) 53 53 54 def save(self ):54 def save(self, force_insert=False, force_update=False): 55 55 import datetime 56 56 if not self.id: 57 57 self.created = datetime.date.today() 58 return super(Article, self).save( )58 return super(Article, self).save(force_insert, force_update) 59 59 60 60 def __unicode__(self): 61 61 return self.headline -
django/django/tests/regressiontests/serializers_regress/models.py
227 227 class ModifyingSaveData(models.Model): 228 228 data = models.IntegerField(null=True) 229 229 230 def save(self ):230 def save(self, force_insert=False, force_update=False): 231 231 "A save method that modifies the data in the object" 232 232 self.data = 666 233 super(ModifyingSaveData, self).save( raw)233 super(ModifyingSaveData, self).save(force_insert, force_update) 234 234 235 235 # Tests for serialization of models using inheritance. 236 236 # Regression for #7202, #7350 -
django/django/docs/topics/db/models.txt
688 688 name = models.CharField(max_length=100) 689 689 tagline = models.TextField() 690 690 691 def save(self ):691 def save(self, force_insert=False, force_update=False): 692 692 do_something() 693 super(Blog, self).save( ) # Call the "real" save() method.693 super(Blog, self).save(force_insert, force_update) # Call the "real" save() method. 694 694 do_something_else() 695 695 696 696 You can also prevent saving:: … … 699 699 name = models.CharField(max_length=100) 700 700 tagline = models.TextField() 701 701 702 def save(self ):702 def save(self, force_insert=False, force_update=False): 703 703 if self.name == "Yoko Ono's blog": 704 704 return # Yoko shall never have her own blog! 705 705 else: 706 super(Blog, self).save( ) # Call the "real" save() method.706 super(Blog, self).save(force_insert, force_update) # Call the "real" save() method. 707 707 708 708 It's important to remember to call the superclass method -- that's that 709 709 ``super(Blog, self).save()`` business -- to ensure that the object still gets -
django/django/docs/ref/contrib/sitemaps.txt
325 325 326 326 class Entry(models.Model): 327 327 # ... 328 def save(self ):329 super(Entry, self).save( )328 def save(self, force_insert=False, force_update=False): 329 super(Entry, self).save(force_insert, force_update) 330 330 try: 331 331 ping_google() 332 332 except Exception: