I'm just trying to display a basic image that is stored in my static folder but nothing is showing up. I have ran collectstatic but nothing.
Path: /static/logos/IMG_1793.jpg
(That is what is shown when printing tenant.image.url)
Settings.html:
<img src="{{ imagePath }}" alt="{{ tenant.name }}">
I have also tried: src="{% static imagePath %}"
Views.py
def settingsPage(request):
tenant = get_tenant(request)
imagePath = tenant.image.url
context = {'tenant': tenant, 'imagePath': imagePath}
return render(request, 'setting/settings.html', context)
CodePudding user response:
In an img tag src attribute you normally put the URL of an image. So if you know the URL just put it there instead of putting the image name.
<img src="{{ tenant.image.url }}" alt="{{ tenant.name }}">
Et voilà!
CodePudding user response:
if you are in developer mode
in settings.py
make sure debug is false (DEBUG = False)
and you specified STATIC_ROOT = 'static/'
