Neither Django nor any maintained Python framework has an automatic match between file paths on the server and URLs - this is some static HTML coming from the pre-1.0 Web - and it's something that happens in CGI applications, or in technologies such as PHP or Asp.
What you need for the href
of your page is the address for a view, just like any other view in Django. The code of this view will return, instead of HTML, an image file, which is marked as such in HTTP headers. (The framework does this automatically).
Within the Python code of this view, you can choose to match the path that comes in the URL directly to files on the disk, although this is a bad security practice. Technologies that do this by default took years to close all (if any) security flaws derived from this (for example, the user putting directories with the name ".." in URL could access any file visible by the HTTP server process on the server - this trivial vulnerability has persisted for years in some technologies.)
Of course you can put your files in the configured folder
to serve static resources - below it there is a match between the path passed in the URL and the /static/...
directory structure - and as this is done by the framework, the possible loopholes are already well resolved.
But most normal in these cases is having an image generated by the application, from
dynamic form - either at each access, or a graph generated at each
time interval, etc ... in this case, enter the idea of the view -
The serve(request, caminho_do_arquivo)
function can be used in your view to serve a file directly (import it with from django.contrib.staticfiles.views import serve
).
The file path can be associated with an image ID in the database - and never be exposed in the URL if you prefer