Ticket #12338: django-models-doc.diff

File django-models-doc.diff, 1.3 KB (added by Daniel Hahler, 15 years ago)

Patch against trunk

  • docs/topics/db/models.txt

     
    726726        name = models.CharField(max_length=100)
    727727        tagline = models.TextField()
    728728
    729         def save(self, force_insert=False, force_update=False):
     729        def save(self, *args, **kwargs):
    730730            do_something()
    731             super(Blog, self).save(force_insert, force_update) # Call the "real" save() method.
     731            super(Blog, self).save(*args, **kwargs) # Call the "real" save() method.
    732732            do_something_else()
    733733
    734734You can also prevent saving::
     
    737737        name = models.CharField(max_length=100)
    738738        tagline = models.TextField()
    739739
    740         def save(self, force_insert=False, force_update=False):
     740        def save(self, *args, **kwargs):
    741741            if self.name == "Yoko Ono's blog":
    742742                return # Yoko shall never have her own blog!
    743743            else:
    744                 super(Blog, self).save(force_insert, force_update) # Call the "real" save() method.
     744                super(Blog, self).save(*args, **kwargs) # Call the "real" save() method.
    745745
    746746It's important to remember to call the superclass method -- that's that
    747747``super(Blog, self).save()`` business -- to ensure that the object still gets
Back to Top