当前位置: 动力学知识库 > 问答 > 编程问答 >

Django image. Not correct url

问题描述:

I have image files from:

imgage = models.ImageField(upload_to="site_media/media")

but if I display this photos in template url to photo is:

bad url = http://127.0.0.1:8000/photo/site_media/media/django__white_and_green__by_aruseni-d59g56q.png

correct url = http://127.0.0.1:8000/site_media/media/django__white_and_green__by_aruseni-d59g56q.png

How to remove 'photo' from this url?

<img src="{{ p.img.url }}"/>

网友答案:

Put a / in front of what you have for MEDIA_URL in settings.py.

分享给朋友:
您可能感兴趣的文章:
随机阅读: