In my view I have a function that generates a file but does not return anything. I want the file to be generated in a specific folder in MEDIA_ROOT
and saved in my models but I’m not sure how exactly to go about doing it. Here is the relevant section of my view:
writer = get_writer(output_format, output_dir)
This function generates a file in the stated directory. I want to save it to a specific directory relevant to my MEDIA_ROOT
.
Here is the relevant section of my settings.py file:
MEDIA_URL='/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
The destination directory, for example, can be media/destination_directory
but I’m not sure how to write the path relative to MEDIA_ROOT