Ticket #8679: 8679.docs-tests-save.diff

File 8679.docs-tests-save.diff, 4.1 KB (added by Julien Phalip, 16 years ago)
  • django/django/tests/modeltests/save_delete_hooks/models.py

     
    1616
    1717    def save(self, force_insert=False, force_update=False):
    1818        print "Before save"
    19          # Call the "real" save() method
     19        # Call the "real" save() method
    2020        super(Person, self).save(force_insert, force_update)
    2121        print "After save"
    2222
  • django/django/tests/modeltests/model_forms/models.py

     
    5151    categories = models.ManyToManyField(Category, blank=True)
    5252    status = models.IntegerField(choices=ARTICLE_STATUS, blank=True, null=True)
    5353
    54     def save(self):
     54    def save(self, force_insert=False, force_update=False):
    5555        import datetime
    5656        if not self.id:
    5757            self.created = datetime.date.today()
    58         return super(Article, self).save()
     58        return super(Article, self).save(force_insert, force_update)
    5959
    6060    def __unicode__(self):
    6161        return self.headline
  • django/django/tests/regressiontests/serializers_regress/models.py

     
    227227class ModifyingSaveData(models.Model):
    228228    data = models.IntegerField(null=True)
    229229
    230     def save(self):
     230    def save(self, force_insert=False, force_update=False):
    231231        "A save method that modifies the data in the object"
    232232        self.data = 666
    233         super(ModifyingSaveData, self).save(raw)
     233        super(ModifyingSaveData, self).save(force_insert, force_update)
    234234
    235235# Tests for serialization of models using inheritance.
    236236# Regression for #7202, #7350
  • django/django/docs/topics/db/models.txt

     
    688688        name = models.CharField(max_length=100)
    689689        tagline = models.TextField()
    690690
    691         def save(self):
     691        def save(self, force_insert=False, force_update=False):
    692692            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.
    694694            do_something_else()
    695695
    696696You can also prevent saving::
     
    699699        name = models.CharField(max_length=100)
    700700        tagline = models.TextField()
    701701
    702         def save(self):
     702        def save(self, force_insert=False, force_update=False):
    703703            if self.name == "Yoko Ono's blog":
    704704                return # Yoko shall never have her own blog!
    705705            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.
    707707
    708708It's important to remember to call the superclass method -- that's that
    709709``super(Blog, self).save()`` business -- to ensure that the object still gets
  • django/django/docs/ref/contrib/sitemaps.txt

     
    325325 
    326326    class Entry(models.Model):
    327327        # ...
    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)
    330330            try:
    331331                ping_google()
    332332            except Exception:
Back to Top