I have a model where there is a ImageField but in the template doesn't appears. The upload of the image is OK (in media_root/one/image.jpg)
Settings.py:
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media_root")
Urls.py
(...)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += staticfiles_urlpatterns()
Models.py
class myModel1(models.Model):
__(...)
__image = models.ImageField(upload_to='one', default="")
__(...)
And on my template, I make this:
<img src="{{ myModel1.image.url }}" alt="{{ myModel1.name }} image" />
And on the HTML is like:
(...)**src="/media/one/photo_p33Mo8a.jpg"**(...)
But the image is not displayed
error 404 not found:
GET http://localhost:8000/media/one/photo_p33Mo8a.jpg 404 (NOT FOUND)
Can someone help me?
PD: Sorry, my first time writing on stackOverFlow.
Have to comment that in the media_root/one/ there appears the image, but the folder /media/ is still empty.
FOLDER STRUCTURE:
Proyect:
___app_folder
________media
________models.py....
___media_root
________one
____________image.jpg
___mainFolder(settings,urls..)
___static_root(...)