def get_upload_to(instance, filename): """ Generate funny file path / url """ # TODO: attach celery command (if that's what it's called) to resize images or do other stuff # maybe it is possible to extend image or other models with fields for randomized parts of url hexdigest = githash(instance.file.read()) folder1 = hexdigest[:2] folder2 = hexdigest[2:4] folder3 = hexdigest folder = os.path.join(folder1, folder2, folder3, "o") name, ext = splitext(filename) return os.path.join(folder, slugify(name) + ext)
def save(self, *args, **kwargs): # convert markdown to html and store it self.body_html = markdown(self.body) self.slug = slugify(self.title) super(Entry, self).save(*args, **kwargs)