[Answer]-Is there any way to distinguish if user adding new data to database or just changing old data in django?

1👍

The save method is called both when an object is created and when it is updated.

However, when an object is being created, the pk of the object is None until save finishes. So what you can do is overwriting the save method of your models and check whether the object being saved has a pk set to None.

Namely

def save(self, *args, **kwargs):
    if self.pk == None:
        # this object is being created
    else:
        # this object is being updated

Leave a comment