Django MEDIA_URL and MEDIA_ROOT

前端 未结 13 1299
天命终不由人
天命终不由人 2020-11-22 11:36

I\'m trying to upload an image via the Django admin and then view that image either in a page on the frontend or just via a URL.

Note this is all on my local machine

13条回答
  •  佛祖请我去吃肉
    2020-11-22 12:19

    Your setting is all right. Some web servers require to specify the media and static folder files specifically. For example in pythonanywhere.com you have to go to the 'Web' section and add the url od the media folders and static folder. For example:

      URL                     Directory                
    /static/            /home/Saidmamad/discoverthepamirs/static     
    /accounts/static/   /home/Saidmamad/discoverthepamirs/accounts/static    
    /media/            /home/Saidmamad/discoverthepamirs/discoverthepamirs/media    
    

    I know that it is late, but just to help those who visit this link because of the same problem ;)

提交回复
热议问题