'Django: how to display images from local resource in Chrome other than {% static %} tag
In case I'm:
- at a very early stage of developing;
- using Chrome, which doesn't allow images from local resource, and
- storing my images in a local /static folder,
what could be the best workaround for displaying images, other than through the {% static %} tag?
I have been using {% load static %}...{% static variable/path %} in my templates, but now I'm trying to display images in the admin page, which requires a good deal of overriding, and admin templates aren't easy to find where exactly to override.
Lately I tried format_html, as in:
from django.contrib import admin
(...)
@admin.display(description='Foto')
def show_foto(self):
return format_html(
'<img src=https://media.(...)>'
)
Which works fine as long as the image resource isn't local.
Also, Django tags don't seem to work inside format_html().
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
