def set_image(self): """This code must be in its own method since the fetch functions need credits to be set. m2m fields are not yet set at the end of either the save method or post_save signal.""" if not self.image: scrape_image(self)
def set_image(self): """This code must be in its own method since the fetch functions need credits to be set. m2m fields are not yet set at the end of either the save method or post_save signal.""" if not self.image: scrape_image(self) # If still no image then use first contributor image if not self.image: contributors = self.get_primary_contributors() if contributors: self.image = contributors[0].image self.save(set_image=False) # If still not image then default if not self.image: filename = settings.STATIC_ROOT + 'music/images/default.png' if os.path.exists(filename): image = File( open(filename, 'rb') ) image.name = 'default.png' self.image = image self.save(set_image=False)
def save(self, *args, **kwargs): super(TrackContributor, self).save(*args, **kwargs) if not self.image: scrape_image(self)