Beispiel #1
0
    def full_clean(self, **kwargs):
        # Set name by filename:
        if not self.name:
            filename = Path(self.file.name).name
            self.name = clean_filename(filename)

        return super().full_clean(**kwargs)
Beispiel #2
0
def get_filename(filename, request):
    random_string = get_random_string()
    filename = clean_filename(filename)
    filename = f'{random_string}/{filename}'
    logger.info(f'Upload filename: {filename!r}')
    return filename