I seem do not understand what i am doing wrong. I have done research online to see if there is any changes, but yet none. Bellow is what i did
settings.py
STATIC_URL = '/static/'
STATIC_ROOT=[
os.path.join(BASE_DIR,"static"),
]
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
url.py
urlpatterns +=static (settings.STATIC_URL,document_root=settings.STATIC_ROOT)
urlpatterns +=static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
model.py
class product(models.Model):
imageone = models.ImageField(upload_to="productimage",null=True,blank=False)
views.py
def home(request):
product= product.objects.all()
context={'proudct':product}
template_name="name.html"
return render(request,template_name,context)
in template
{% for products in product %}
<img src="{{proudcts.imageone.url}}">
{% endfor %}
When i upload image from the admin, i get image location at http://127.0.0.1:8000/media/productimage/homepagebizalAfric.jpg, but image does not display. What i my doing wrong ?