I'm trying to override the save method of models so that when a new workbook is created it will be saved and exported immediately to a .json file, this would be a form of automatic backup, but when you register a new workbook it exports all the items minus the last one registered, but it should export all, could anyone give me an example of how kindly to override this method correctly ??
def save(self, filename="books", *args, **kwargs):
get = serializers.serialize("json", Books.objects.all())
bkp = open("backup/" + filename + ".json", "w")
bkp.write(get)
super(Books, self).save(*args, **kwargs)