django-gsheets
django-gsheets copied to clipboard
2 ways sync issue: my change is not push to google sheet
Use case:
- data are filled first in the google sheet
- I synchronized the data thanks to django-ghseets into a local database
- I edit some row
- I synchronized to push my change to google sheets
- I get my row update from google sheets and I lost my change (and my change is not in the google sheet).
Is it possible to push my changes to the google sheet with a signals?
Here is a solution using a signal
@receiver(post_save, sender=Person)
def gsheets_sync(sender, instance=None, **kwargs):
print('post save callback')
instance.push_to_sheet()
My choice finally goes to this better solution:
@receiver(post_save, sender=Person) #add this
def create_person(sender, instance, created, **kwargs):
if not created:
Person.push_to_sheet()