My web page makes an AJAX call to the server to dynamically select an image for display. The problem I’ve run into is that the STATIC_URL variable evaluates to an empty string, and so the image fails to load.
This is the code I’m using the render the path to the image.
text = "<img src=\"{{ STATIC_URL }}/images/%s\"> %s" % (ball_file, val)
t = Template(text)
tt = t.render(Context())
Any help would be much appreciated.
Why even use Template ? Wouldn’t this work ?
Note that
STATIC_URLshould contain the trailing slash, hence%simagesin this example instead of%s/images.