Package: django-iconify
This re-usable app hepls integratingIconifyinto Django projects.
Iconify is a unified icons framework, providing access to 40,000+ icons
from different icon sets.Iconify replaces classical icon fonts, claiming that such fonts would
get too large for some icon sets out there. Instead, it provides an API
to add icons in SVG format from its collections.django-iconifyeases integration into Django. Iconify, to be performant,
uses a server-side API to request icons from (in batches, with transformations
applied, etc.). Upstream provides a CDN-served central API as well as
self-hosted options written in PHP or Node.js, all of which are undesirable
for Django projects.django-iconifyimplements the Iconify API as a
re-usable Django app.InstallationTo adddjango-iconifyto a project, first add it as dependency to your
project, e.g. usingpoetry:$ poetry add django-iconifyThen, add it to yourINSTALLED_APPSsetting to make its views available
later:INSTALLED_APPS = [
    ...
    "dj_iconify.apps.DjIconifyConfig",
    ...
]You need to make theJSON collectionavailable by some means. You can
download it manually, or use your favourite asset management library. For
instance, you could usedjango-yarnpkgto depend on the@iconify/jsonYarn package:YARN_INSTALLED_APPS = [
  "@iconify/json",
]
NODE_MODULES_ROOT = os.path.join(BASE_DIR, "node_modules")No matter which way, finally, you have to configure the path to the
collections in your settings:ICONIFY_JSON_ROOT = os.path.join(NODE_MODULES_ROOT, "@iconify", "json")If you do not usedjango-yarnpkg, construct the path manually, ot use
whatever mechanism your asset manager provides.You can configure which icon collections are available using two settings:ICONIFY_COLLECTIONS_ALLOWED = [“foo”, “bar”]This list controls which collections can be used. If it is set to a
non-empty list, only the collections listed are allowed.ICONIFY_COLLECTIONS_DISALLOWED = [“foo”, “bar”]This list, on the other hand, controls which collections cannot be used.
If this list contains values, whileCOLLECTIONS_ALLOWEDdoesn’t, all
collections except the listed ones are allowed.The allow/disallow feature can be used in cases where only a limited set
of collections should be available due to design principles or for legal
reasons.Finally, include the URLs in yoururlpatterns:from django.urls import include, path

urlpatterns = [
    path("icons/", include("dj_iconify.urls")),
]UsageIconify SVG FrameworkTo use theIconify SVG Framework, get its JavaScript from somewhere
(e.g. usingdjango-yarnpkgagain, or directly from the CDN, from your
ow nstatic files, or wherever).django-iconifyprovides a view that returns a small JavaScript snippet
that configures theIconify SVG Frameworkto use its API endpoints. In
the following example, we first load this configuration snippet, then
include theIconify SVG Frameworkfrom the CDN (do not do this in
production, where data protection matters):<script type="text/javascript" src="{% url 'config.js' %}"></script>
<script type="text/javascript" src="https://code.iconify.design/1/1.0.6/iconify.min.js"></script>Loading SVG directly (“How to use Iconify in CSS”)django-iconifyalso implements the direct SVG API. For now, you have to use
Django’s regular URL reverse resolver to construct an SVG URL, or craft it
by hand:<img src="{% url 'iconify_svg' 'mdi' 'account' %}?rotate=90deg %}" />Documentation on what query parameters are supported can be found in the
documentation onHow to use Iconify in CSS.In the future, a template tag will be available to simplify this.Including SVG in template directlyNot implemented yetIn the future, a template tag will be available to render SVG icons directly
into the template, which can be helpful in situations where retrieving external
resources in undesirable, like HTML e-mails.ExampleThe source distribution as well as theGit repositorycontain a full example
application that serves the API under/icons/and a test page under/test.html.It is reduced to a minimal working example for the reader’s convenience.