mirror of https://github.com/django/django.git
Updated a few save() methods on models to accept force_insert and force_update
parameters. Required as a consequence of [8670] (so they can be used with create()). git-svn-id: http://code.djangoproject.com/svn/django/trunk@8673 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a46d3ebfcc
commit
65c0846c45
|
@ -74,10 +74,10 @@ class Comment(BaseCommentAbstractModel):
|
|||
def __unicode__(self):
|
||||
return "%s: %s..." % (self.name, self.comment[:50])
|
||||
|
||||
def save(self):
|
||||
def save(self, force_insert=False, force_update=False):
|
||||
if self.submit_date is None:
|
||||
self.submit_date = datetime.datetime.now()
|
||||
super(Comment, self).save()
|
||||
super(Comment, self).save(force_insert, force_update)
|
||||
|
||||
def _get_userinfo(self):
|
||||
"""
|
||||
|
@ -178,7 +178,7 @@ class CommentFlag(models.Model):
|
|||
return "%s flag of comment ID %s by %s" % \
|
||||
(self.flag, self.comment_id, self.user.username)
|
||||
|
||||
def save(self):
|
||||
def save(self, force_insert=False, force_update=False):
|
||||
if self.flag_date is None:
|
||||
self.flag_date = datetime.datetime.now()
|
||||
super(CommentFlag, self).save()
|
||||
super(CommentFlag, self).save(force_insert, force_update)
|
||||
|
|
|
@ -64,7 +64,7 @@ class RequestSite(object):
|
|||
def __unicode__(self):
|
||||
return self.domain
|
||||
|
||||
def save(self):
|
||||
def save(self, force_insert=False, force_update=False):
|
||||
raise NotImplementedError('RequestSite cannot be saved.')
|
||||
|
||||
def delete(self):
|
||||
|
|
|
@ -14,9 +14,10 @@ class Person(models.Model):
|
|||
def __unicode__(self):
|
||||
return u"%s %s" % (self.first_name, self.last_name)
|
||||
|
||||
def save(self):
|
||||
def save(self, force_insert=False, force_update=False):
|
||||
print "Before save"
|
||||
super(Person, self).save() # Call the "real" save() method
|
||||
# Call the "real" save() method
|
||||
super(Person, self).save(force_insert, force_update)
|
||||
print "After save"
|
||||
|
||||
def delete(self):
|
||||
|
|
|
@ -16,8 +16,8 @@ class Photo(models.Model):
|
|||
super(Photo, self).__init__(*args, **kwargs)
|
||||
self._savecount = 0
|
||||
|
||||
def save(self):
|
||||
super(Photo, self).save()
|
||||
def save(self, force_insert=False, force_update=False):
|
||||
super(Photo, self).save(force_insert, force_update)
|
||||
self._savecount += 1
|
||||
|
||||
class PhotoForm(ModelForm):
|
||||
|
|
|
@ -13,8 +13,8 @@ class RevisionableModel(models.Model):
|
|||
def __unicode__(self):
|
||||
return u"%s (%s, %s)" % (self.title, self.id, self.base.id)
|
||||
|
||||
def save(self):
|
||||
super(RevisionableModel, self).save()
|
||||
def save(self, force_insert=False, force_update=False):
|
||||
super(RevisionableModel, self).save(force_insert, force_update)
|
||||
if not self.base:
|
||||
self.base = self
|
||||
super(RevisionableModel, self).save()
|
||||
|
|
Loading…
Reference in New Issue