I'm using django-filebrowser, with a model field declared as
image = FileBrowseField("Image", max_length=200, blank=True, null=True)
and using the image in a template with
{% version_object obj.image "thumb" as img %}
In admin, the filebrowser allows the user to select a directory in place of an image. When this happens (accidentally), the version_object template tag above raises an IOError: "[Errno 21] Is a directory".
This is pretty disastrous as it breaks the whole page the image appears on. How can I...
The "SELECT_FORMATS" setting sounds like it might help, but the documentation is unclear:
Set different Options for selecting elements from the FileBrowser:
SELECT_FORMATS = getattr(settings, "FILEBROWSER_SELECT_FORMATS", { 'file': ['Folder','Image','Document','Video','Audio'], 'image': ['Image'], 'document': ['Document'], 'media': ['Video','Audio'], })
When using the browse-function for selecting Files/Folders, you can use an additional query-attribute type in order to restrict the choices.
I don't understand how (or if) this setting applies to the admin interface.
Try setting the format
attribute on your field
image = FileBrowseField("Image", format='image', max_length=200, blank=True, null=True)