If you implement an image uploader in Django, you can save the image but you can't read it! I thought that I might run into various problems, so I will share it. I don't think there are any mistakes in writing settings.py and models.py, so maybe the big chobo miss points are as follows.
urls.py
from django.conf import settings
from django.conf.urls import url, include
from django.conf.urls.static import static
from django.contrib import admin
urlpatterns = [
url(r'^myapp/', include('myapp.urls',namespace='myapp')),
url(r'^admin/', admin.site.urls),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
I think it can be avoided in general like this. The rest is a template
{% for i in result_list %}
<img src="{{ i.image_url.url }}">
{% endfor %}
It will be OK if you call it like this.
Recommended Posts