save only table fields that were passed onto the dictionary

I have a model like this :

class Person(models.Model):
    name = models.CharField(max_length=250, blank=True, null=True)
    created_at = models.DateTimeField(auto_now_add=True)

class Employee(models.Model):
    p = models.ForeignKey("Person", on_delete=models.CASCADE, blank=True, null=True)
    department = models.TextField(blank=True, null=True)
    hasResigned = models.IntegerField(blank=True, null=True)

I have pre-filled data like this :

If I execute this, the fields not present in the dictionary get wiped out from the existing row. (NULL)

    e_dict = {}
    e_dict['id'] = 1
    e_dict['department'] = 'Engineering'
    emp = Employee(**e_dict)
    emp.save()

I’m using the above code in a method for multiple update methods (and if e_dict['id'] is 0 then emp.save() will create).

if 'hasResigned' in form:
    e_dict['hasResigned'] = server.get("hasResigned")

I want emp.save() to update only fields that were passed on in the dictionary.

Hi.
See the documenation for the save method (Model instance reference | Django documentation | Django).

You should use something like:

emp.save(force_update=True, update_fields=list(e_dict.keys()))