MeanPug / django-gsheets

Django app for keeping models and google sheets synced
https://www.meanpug.com/sync-data-to-and-from-google-sheets-with-django-gsheets/
MIT License
60 stars 25 forks source link

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

Open yjacolin opened 2 years ago

yjacolin commented 2 years ago

Use case:

Is it possible to push my changes to the google sheet with a signals?

yjacolin commented 2 years ago

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