Open CyberFox001 opened 1 year ago
After some testes: The files are uploaded as media file. So, it's managed by django as any media file.
But, if I use the preference in a template like this:
<img class="forum_logo d-inline-block align-text-top" alt="logo" src="{{ global_preferences.general__forum_logo }}"/>
The URL did not include the value of MEDIA_ROOT setting.
So, instead of having the URL: http://127.0.0.1:8000/media/dynamic_preferences/general__forum_logo/logo.png
I got: http://127.0.0.1:8000/dynamic_preferences/general__forum_logo/logo.png
@CyberFox001 I came into same problem about URL. How to solve it?
Hi, to answer your question, the files are stored as media files. If you want to get the relative URL, you should use {{ global_preferences.general__forum_logo.url }}
in a template. If it doesn't include the full URL, you can use either the get_media_prefix
template tag or the media URL context processor
as described in https://stackoverflow.com/a/42563023 to build a full URL.
The documentation of the preference type
FilePreference
is a bit light.Event after searched info in the documentation website: https://django-dynamic-preferences.readthedocs.io
There is some missing informations. Like:
And the example is a bit short. Is it an example of preference definition, or also an example of usage ? It's a bit confusing.
Maybe a section dedicated to this type of preference could help understand it.
I would love to help about it, but as I didn't understand how to use FilePreference, I can do nothing.