Stephen McDonald  committed 2a49665 Draft

Allow FileBrowser fields with defined upload directories to create their own directories.

  • Participants
  • Parent commits 1945b5d

Comments (0)

Files changed (1)

File filebrowser_safe/

 # django imports
 from django.db import models
 from django import forms
+from import default_storage
 from django.forms.widgets import Input
 from django.db.models.fields import Field
 from django.template.loader import render_to_string
 # filebrowser imports
 from filebrowser_safe.settings import *
 from filebrowser_safe.base import FileObject
-from filebrowser_safe.functions import url_to_path
+from filebrowser_safe.functions import url_to_path, get_directory
 class FileBrowseWidget(Input):
     def render(self, name, value, attrs=None):
         if value is None:
             value = ""
+        if
+            fullpath = os.path.join(get_directory(),
+            if not default_storage.isdir(fullpath):
+                default_storage.makedirs(fullpath)
         final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
         final_attrs['search_icon'] = URL_FILEBROWSER_MEDIA + 'img/filebrowser_icon_show.gif'
         final_attrs['directory'] =