[Django]-Django static templatetag not displaying SVG

0👍

I found the issue. In settings.py, it should be mimetypes.add_type('image/svg+xml', '.svg', True). image should be singular.

👤NJP

0👍

I faced a similar issue.I would recommend you to use :
src=”{{ STATIC_URL }} images/right-arrow.svg” instead of src=”{% static ‘images/right-arrow.svg’ %}”

svg format might not always identify django’s method of obtaining staticfile contents.Hope this helps 🙂

0👍

Add this in your settings.py file.

import mimetypes

mimetypes.add_type("image/svg+xml", ".svg", True)
mimetypes.add_type("image/svg+xml", ".svgz", True)

In your cases you have added images in add_type which should be singular (image).

0👍

You are loading staticfiles and using static?

This is wrong.

Try changing {% load staticfiles %} <img src="{% static 'images/right-arrow.svg' %}" /> to
{% load static %} <img src="{% static 'images/right-arrow.svg' %}" /> and you also need to consider which app you should find your static files.

Leave a comment