0

for fun I am monitoring the free disk space on my linux box. I have indexed the mount points and store the contents in a MySQL database. Now I want to display this info using django. A cron job automatically creates plots of the free space for the last 24 hours. They are named "graph_day_drive_1.png" to "graph_day_drive_3.png", where the number stands for the id of the mount point. I have put these images in the static directory of my app. Now, I want to display them when showing a details view for a selected mount point. I've read that the usual way to access an image is:

    <img src="{% static "diskspace/graph_day_drive_1.png" %}" alt="last 24h"/><br>

which, of course, displays the same image regardless of which drive I select. I've tried using the following (drive refers to the model I read from the database):

    <img src="{% static "diskspace/graph_day_drive_{{ drive.id }}.png" %}" alt="last 24h"/><br>

but it doesnt work as it creates the following html code:

<img src="/static/diskspace/graph_day_drive_%7B%7B%20drive.id%20%7D%7D.png" alt="letzte 24h"/>

which, obviously, doesn't work. Can anyone tell me the proper way to access these images?

b0wter
  • 148
  • 7

0 Answers0