Skip to content
Snippets Groups Projects
Commit 2507ecc2 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Create upload directory if it does not exist

parent b07181fe
No related branches found
No related tags found
1 merge request!125Move path_and_rename to core_helpers.py and delete old helper.py
Pipeline #675 failed
......@@ -133,5 +133,8 @@ def path_and_rename(instance, filename: str, upload_to: str = "files") -> str:
# set filename as random string
new_filename = '{}.{}'.format(uuid4().hex, ext)
# Create upload directory if necessary
os.makedirs(os.path.join(settings.MEDIA_ROOT, upload_to), exist_ok=True)
# return the whole path to the file
return os.path.join(upload_to, new_filename)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment