Hello,
Indeed, if we took a big step further and provided an API to configure multiple file storage backends, that would make sense.
Currently we have two hardcoded ones: the default, which is used for media files, and the static, which is used for static files.
Essentially your proposal means reformatting the current file-related settings to this structure:
FILE_STORAGES = {
‘media’: {
‘BACKEND’: settings.DEFAULT_FILE_STORAGE,
‘OPTIONS’: {
‘location’: settings.MEDIA_ROOT,
‘base_url’: settings.MEDIA_URL,
# possible override of settings.FILE_CHARSET
},
},
‘static’: {
‘BACKEND’: settings.STATICFILES_STORAGE,
‘OPTIONS’: {
‘location’: settings.STATIC_ROOT,
‘base_url’: settings.STATIC_URL,
# replacement for STATICFILES_FINDERS and STATICFILES_DIRS that would look a lot like template loaders
# possible override of settings.FILE_CHARSET
},
}
}
The FILE_UPLOAD_* settings wouldn’t change because they don’t affect file storage.
It isn’t entirely clear to me what the best way to reconcile “default” and “media” would be. Currently they’re effectively the same but settings are named inconsistently for historical reasons. In addition this would require an API for getting a file storage backend.
This is a much more invasive change as it would require everyone to update their settings. However it would meet some use cases much better. Pluggable apps that need to store files could document that they’ll use the backend with a given name it if exists and fall back to the default backend otherwise. That’s exactly what django.contrib.sessions currently does with cache.
How do people feel about this alternative proposal?
--
Aymeric.
> --
> You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
django-develop...@googlegroups.com.
> To post to this group, send email to
django-d...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/django-developers.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/20151107125832.440abc17%40corvis.
> For more options, visit
https://groups.google.com/d/optout.