Skip to content

Data URI your Images in Django

Posted in Django

As I read the book, Two Scoops of Django, I come across lots of best practices (I wasn’t expecting otherwise though).

One that caught my eye was Data URI scheme. Simply put, this allows you to convert your images or css into some kinda gibberish things. In a much simpler way, the object (image, css) is encoded into its data form.

“This technique allows normally separate elements such as images and style sheets to be fetched in a single request rather than multiple HTTP requests, which can be more efficient.”

-quote from Wikipedia

Did you read the article linked above? If not, you can see an example of it to understand better, probably.

Append this filter/tag into your project, and just profit!

I hope you find the above snippet useful.

Will see you in the next one!