django-gsheets icon indicating copy to clipboard operation
django-gsheets copied to clipboard

2 ways sync issue: my change is not push to google sheet

Open yjacolin opened this issue 3 years ago • 1 comments

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?

yjacolin avatar Dec 18 '21 11:12 yjacolin

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()

yjacolin avatar Jan 30 '22 11:01 yjacolin