Djangocms and django-filer: upload files to a specific folder

I installed djangocms 3.1.0 with django-filer 0.9.11 and I created two custom djangocms plugins extending django-filer (as described in the documentation ).

Everything works fine, but now I only need to set a specific folder for one of these plugins where I want to save the downloaded file. Currently, the files are saved using settings DEFAULT_FILER_STORAGES

.

Is there a way to set a specific storage folder inside the plug-in?

+3


source to share


1 answer


Without seeing your code, I can’t say for sure that you are taking the same approach, but let me explain how I downloaded the files to a specific folder, and perhaps you can make it work yourself. Otherwise, if you provide more details, I can help more.

I have a script that creates a new feeder image in a specified folder and links it to my model. I did it this way:



from filer.models import Folder, Image

my_file = File(open(file_goes_here))
my_folder = Folder.objects.get_or_create(name='My Folder Name')[0]

filer_image = Image.objects.create(original_filename='My original file name', 
                                   file=my_file, 
                                   folder=my_folder)

new_image = MyModelImage(image=filer_image)
new_image.save()

      

Hope this helps ?!

+2


source







All Articles