Display an image located in the database in Django

前端 未结 3 657
失恋的感觉
失恋的感觉 2021-02-09 09:56

I just want to display an image that i have uploaded through the admin module, through an html image tag on a web page. The image is located in /home/user/work/djcode/media/chic

3条回答
  •  佛祖请我去吃肉
    2021-02-09 10:39

    Try doing the following:

    from django.conf import settings
    from django.conf.urls.static import static
    from . import views
    
    urlpatterns = [
                .....
    ] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
    

提交回复
热议问题