Use iconic.app icons in your Django templates
17 Aug 2021
iconic.app icons are a wonderful, free, set of icons. You can use them wherever you like. How you use them is by copy and pasting and SVG into your templates. That can be a bit cumbersome.
But there is a better way for your Django (and Jinja) templates: use iconic and you can include any icon by name:
{% load iconic %}
{% iconic_icon "announcement" size=48 class="h-4 w-4 inline" %}
Easy peasy.
Links
Credits
- Thanks to @jamesm and @ormanclark for the fantastic icons. You should definitely buy the “Pro” icons
- The python package is a fork of the heroicons package by Adam Johnson. Check out his announcement post for more information
Caveats
Right now this package does not support the Pro icons in any way - you still need to copy and paste those SVGs.
Full Instructions
Install the package
pip install iconic[django]
Add it to your INSTALLED_APPS
:
# settings.py
INSTALLED_APPS = [
...,
'iconic',
...,
]
Then just load it and use it in your templates:
{% load iconic %}
{% iconic_icon "announcement" size=48 class="h-4 w-4 inline" data_controller="announcement" %}