I have a Django 1.8.4 site with Django CMS 3.1.3. Via the djangocms-picture plugin I want the editors to be able to upload images to the site. If I upload an image on a page using this plugin, the image ends up in the following folder on the server:
[PATH_TO_APP_ROOT]/media/cms_page_media/8/
Where ‘8’ is the id of the page. When I browse the page, the link to the image is given as
https://[MY_SITE]/media/cms_page_media/8/my_image.png
But this link is not correct and I get a 404. I am having a hard time figuring out what I am missing but it seems that there is some URL setting that should be changed.
In settings.py I have:
MEDIA_ROOT = os.path.join([PATH_TO_APP_ROOT], "media")
MEDIA_URL = "/media/"
Where [PATH_TO_APP_ROOT]
is the same as given above. I have not changed any of the media-settings given in the Django CMS docs so they should all be default. I am confused that the server looks for the image in /media/cms_page_media/8/my_image.png
as the cms_page_media
-part of this URL comes from CMS_PAGE_MEDIA_PATH
which is not a URL setting(?). What setting do I need to look for to correct this?
Note that everything works perfectly for me in DEV (locally) - the problem is only on the production server.
Finally had time to look into this: The problem was that the web server (pythonanywhere) was not configured correctly. In their admin tool, I had to specify the path to media folder. When I did this, it worked, without having to change any Django settings.
more info here: https://help.pythonanywhere.com/pages/DjangoStaticFiles