How do I include image files in Django templates?

前端 未结 11 1698
时光说笑
时光说笑 2020-11-27 10:35

I\'m new to Django and I\'m trying to learn it through a simple project I\'m developing called \'dubliners\' and an app called \'book\'. The directory structure is like this

11条回答
  •  误落风尘
    2020-11-27 11:05

    Another way to do it:

    MEDIA_ROOT = '/home/USER/Projects/REPO/src/PROJECT/APP/static/media/'
    MEDIA_URL = '/static/media/'
    

    This would require you to move your media folder to a sub directory of a static folder.

    Then in your template you can use:

    
    

提交回复
热议问题