def save(self, *args, **kwargs):
    for (hash_field_obj, model, direct, m2m) in [self._meta.get_field_by_name('md5'), self._meta.get_field_by_name('sha256')]:
        if (not getattr(self, hash_field_obj.name)):
            digest = hash_field_obj.hasher(self.file_content).hexdigest()
            setattr(self, hash_field_obj.name, digest)
    return super(AbstractFileSample, self).save(*args, **kwargs)
def save(self, *args, **kwargs):
    for (hash_field_obj, model, direct, m2m) in [self._meta.get_field_by_name('md5'), self._meta.get_field_by_name('sha256')]:
        if (not getattr(self, hash_field_obj.name)):
            digest = hash_field_obj.hasher(self.file_content).hexdigest()
            setattr(self, hash_field_obj.name, digest)
    return super(AbstractFileSample, self).save(*args, **kwargs)