Hi everybody,
*Short version :*
Is there a way to choose name of sub-directories' upload files without
hacking core mezzanine code ?
*Long version :*
I created a HomePage class (subclass of Page, RichText) with a field
(FileField type) header_backround to allow user to change it. Then I can
choose where files will be upload by settings upload_to args, ex :
header_background = FileField(verbose_name=_("Image in background header"),
upload_to=upload_to("theme.HomePage.header_background",
"home_backgrounds"),
format="Image", max_length=255)
And when I upload images for the header_background, the files nicely go to
the directory : medias/uploads/site-1/home_backgrounds
( As you can see with "site-1" in the path, i'm in multi-tenancy context).
Ok that what I want...perfect. But...
There is a way to do the same thing with "galleries" or "blog" for instance
without hacking the function upload_to in :
mezzanine/blog/models.py : class BlogPost -> field feature_image
mezzanine/galleries/models.py : class GalleryImage -> fields file
What I tried :
- As previously said changing upload_to function args is not a good idea. I
will loose the changes if I upgrade for new Mezzanine version in future.
- For gallery I saw the GALLERIES_UPLOAD_DIR but it seems impossible to
override from settings.py
- I play with UPLOAD_TO_HANDLERS settings in settings.py like:
UPLOAD_TO_HANDLERS = {
'theme.HomePage.header_background': 'home_backgrounds',
}
but it was more a deseparate believe in a lucky solution: I don't
understand the purpose of this setting
--
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.