Django - TypeError - save() got an unexpected keyword argument 'force_insert'

When you are overriding model's save method in Django, you should also pass *args and **kwargs to overridden method. this code may work fine:

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

    img = Image.open(self.image.path)

    if img.height > 300 or img.width > 300:
        output_size = (300,300)
        img.thumbnail(output_size)
        img.save(self.image.path)'

You've overridden the save method, but you haven't preserved its signature. Yo need to accept the same arguments as the original method, and pass them in when calling super.

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

Tags:

Python

Django