0

I'm working on a project where I use Django's admin "power" to manage a few models, which are to be displayed in a visualization (made with JavaScript). Javascript can read the data in json, so I need a way to convert the data for my models to json. I'll use Django's serialization tools.

I figure it makes more sense to generate a json file only when a create / edit / delete action has been performed on the admin side.

How can I make sure a callback (to do the serialization) is triggered every time the data changes in the admin side ?

GuitarExtended
  • 787
  • 2
  • 11
  • 32
  • 2
    You could override the save method on the model? http://stackoverflow.com/questions/4269605/django-override-save-for-model – Jonas Grumann Feb 01 '17 at 15:00
  • or you can use post_save signal https://docs.djangoproject.com/en/1.10/ref/signals/#post-save – mislavcimpersak Feb 01 '17 at 15:08
  • 2
    The serialization should be triggered in an api view when data is requested by the visualization client. Why would you want to duplicate database contents into json files? just create fields for created/updated timestamps and use them to filter recently created/updated instances and serialize them when requested. – trixn Feb 01 '17 at 15:09

0 Answers0