Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django save() got an unexpected keyword argument 'force_insert' error

Tags:

django

save

I'm getting a save() got an unexpected keyword argument 'force_insert' error. From this http://groups.google.com/group/django-users/browse_thread/thread/2471efd68d56ad59 it looks like the answer is to use:

def save(self, *args, **kwargs): 
... 
   super(SiteUser, self).save(*args, **kwargs)

My question is how would you go about specifying force_insert=True or force_insert=False when doing that.

My code is:

   def save(self, force_insert=False, force_update=False):
      if not self.id:
         self.pub_date = datetime.datetime.now()
      self.updated_date = datetime.datetime.now()
      self.description_html = markdown(self.description)
      self.highlighted_code = self.highlight()
      super(Snippet, self).save(force_insert, force_update)
like image 366
Superdooperhero Avatar asked Oct 24 '22 19:10

Superdooperhero


1 Answers

kwargs is a dict. Set it as you would any other dict value.

kwargs['force_insert'] = True
like image 182
Ignacio Vazquez-Abrams Avatar answered Oct 26 '22 22:10

Ignacio Vazquez-Abrams