Django: MEDIA_URL not set in template

后端 未结 2 1417
说谎
说谎 2021-02-05 19:32

I\'ve read a lot of question and article but can\'t find what I\'m missing.

Here is my conf :

settings.py

MEDIA_ROOT = os.path.j         


        
2条回答
  •  孤街浪徒
    2021-02-05 20:13

    models.ImageField has a property called url which gives you the browsable path of your image.

    You should be using artist.artist_image.url instead of prepending MEDIA_URL to your image name manually:

    
    

    --

    Make sure artist_image is not None, otherwise calling .url throws an exception.

提交回复
热议问题