Reputation: 27
I'm trying to refresh the image after pressing the button
I include the image in static files.. im using Django with HTML
Upvotes: 0
Views: 1001
Reputation: 3720
If you're looking to fetch the image again without reloading the page you can do something like this.
<img id="pic" src="{% static 'images/graph.png' %}" onclick="reloadimg()" style="display:none;" />
<script>
function reloadimg(){
var src = "{% static 'images/graph.png' %}";
imageObject = document.getElementById("pic");
imageObject.style.display = 'inline-block';
imageObject.src = src;
}
</script>
Upvotes: 4
Reputation: 422
In django by default if server is running on debug mode, it should refresh,
if it is not refreshing, try running command python manage.py collectstatic
and do hard refresh of page by Ctrl + shift + R
Upvotes: 1