Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save fish2000/1628428 to your computer and use it in GitHub Desktop.

Select an option

Save fish2000/1628428 to your computer and use it in GitHub Desktop.
This ended up being some boilerplate I had to put into all my django-imagekit forks' model fields' functions that got called on pre_save/post_save signals.
def clear_exif_data(self, **kwargs): # signal, sender, instance
"""
Stores ICC profile data in the field before saving, and refreshes
the profile hash if an ICCHashField has been specified.
"""
instance = kwargs.get('instance')
logg.info("--- Clearing exif metadata from %s.%s %s" % (
instance.__class__.__name__, self.name, instance.id))
setattr(instance, self.name, None)
# save if sent asynchronously
dequeue_runmode = kwargs.get('dequeue_runmode', None)
enqueue_runmode = kwargs.get('enqueue_runmode', None)
if dequeue_runmode is not None:
if not dequeue_runmode == enqueue_runmode:
if dequeue_runmode == signalqueue.SQ_RUNMODES['SQ_ASYNC_DAEMON']:
instance.save_base()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment