After posting this message : 
https://groups.google.com/forum/#!topic/mezzanine-users/mpdvQemATiw, I 
investigate to understand the meaning of the UPLOAD_TO_HANDLERS setting.

*What :*
This what to do if you want to change the name of the upload directory for 
galleries.
For instance, we *replace the default name "galleries" by "collections"* :

*Solution :*
I added those lines in default.py file [ to understand default.py see : 
http://mezzanine.jupo.org/docs/configuration.html ]. In example I used an 
app named "theme" :

# Change upload directory name for galleries to : 'collections'
def upload_path_file():
    return 'collections'

def upload_path_zip_import(instance, filename):
    return 'collections/%s' % filename

register_setting(
    name="UPLOAD_TO_HANDLERS",
    description="Function names that will be used for the file field’s 
upload_to argument.",
    editable=False,
    default={
        'galleries.GalleryImage.file': 'theme.defaults.upload_path_file',
        'galleries.Gallery.zip_import': 
'theme.defaults.upload_path_zip_import',
    },
)



*Details :*

The meaning of the UPLOAD_TO_HANDLERS setting :

UPLOAD_TO_HANDLERS = {
    'app.model.field': 'app.module.fonction_to_use'
}

Where "fonction_to_use" is a function used to return the upload path that 
must be able to accept two arguments as described in django documentation : 
https://docs.djangoproject.com/en/1.6/ref/models/fields/#django.db.models.FileField


*I don't understand why* the standard django way doesn't work for the field 
"galleries.GalleryImage.file". Mezzanine raise an error about the number of 
given arguments and that why I have to create two functions 
(upload_path_file and upload_path_zip_import) instead of only one.

*If someone can explain* why (or can show me a better way) ?

Best regards

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to