Skip to main content

django-icons

CI Coverage Status Latest PyPI version

Icons for Django.

Goal

The goal of this project is to provide a single, simple template tag for rendering icons from any icon library in Django templates.

  • Define your icons in your settings, with defaults for name, title and other attributes.
  • Generate icons using template tags.
  • Supports Font Awesome, Material, Bootstrap 3 and images.
  • Add other libraries and custom icon sets by subclassing IconRenderer.

Status

Ready for production. Issues and pull requests welcome, see CONTRIBUTING.md.

Requirements

This package requires a combination of Python and Django that is currently supported.

See "Supported Versions" on https://www.djangoproject.com/download/.

This package uses uv and just for local development.

Documentation

The full documentation is at https://django-icons.readthedocs.io/en/latest/

Installation

  1. Install using pip:

    pip install django-icons
    
  2. Add to INSTALLED_APPS in your settings.py:

    INSTALLED_APPS = (
        # ...
        "django_icons",
        # ...
    )
    
  3. Define an icon:

    DJANGO_ICONS = {
        "ICONS": {
            "edit": {"name": "fa-solid fa-pencil"},
        },
    }
    
  4. In your templates, load the icons library and use the {% icon %} tag. See example below.

Example template

{% load icons %}

<!-- Include your icon library. This example uses Font Awesome 6 through cdnjs. -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">

{% icon 'edit' %}

This will generate the FontAwesome 6 pencil icon in regular style.

<i class="fa-solid fa-pencil"></i>

Add extra classes and attributes to your predefined icon.

{% load icons %}
{% icon 'edit' extra_classes='fa-2xs my-extra-class' title='Update' %}

These will be added to the HTML output.

<i class="fa-solid fa-pencil fa-2xs my-extra-class" title="Update"></i>

Example app

An example app is provided in the folder example. You can run the example app with this command:

just example

Bugs and suggestions

If you have found a bug or if you have a request for additional functionality, please use the issue tracker on GitHub.

https://github.com/zostera/django-icons/issues

License

You can use this under BSD-3-Clause. See LICENSE file for details.

Author

Developed and maintained by Zostera.

Original author: Dylan Verheul.

Thanks to everybody that has contributed pull requests, ideas, issues, comments and kind words.

Please see AUTHORS for a list of contributors.

Origin

Our plans at Zostera for an icon tool originate in https://github.com/dyve/django-bootstrap3. We isolated this into a Font Awesome tool in https://github.com/zostera/django-fa. When using our own product, we felt that the icon tool provided little improvement over plain HTML. Also, Font Awesome's icon names did not match the intended function of the icon.

This is how we came to think of a library that:

  • Took a limited number of arguments
  • Converted those arguments into an icon
  • Was able to support multiple icon libraries
  • Could bind an icon definition to a preset name for easy reuse
  • Could easily be extended by users

This is how we came to write and use django-icons.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_icons-26.2.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_icons-26.2-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file django_icons-26.2.tar.gz.

File metadata

  • Download URL: django_icons-26.2.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for django_icons-26.2.tar.gz
Algorithm Hash digest
SHA256 6856188436592967d670c8ad5644c4e1b393ea7c750a6aae7b0f788e74ad8ef8
MD5 b99e58149a5d2b3bc725e5e3d052801a
BLAKE2b-256 4717d2a0ee35cb8f7e1bf34f88e94ba17a934ce1ba86aebbc8dc8f3bb1af07d1

See more details on using hashes here.

File details

Details for the file django_icons-26.2-py3-none-any.whl.

File metadata

  • Download URL: django_icons-26.2-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for django_icons-26.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ad16007520cd63f5f5e266a5161c7fc0ea23d55a24c6c4b903acd40195d4e800
MD5 4f90ceaf22d26b020a6f658a146ecc35
BLAKE2b-256 7940302518703bd730bb9d20e09235d9e082d2d64bf1390497d28d9b2f1bef44

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

26.2 This release

2 files

26.1

2 files

25.3

2 files

25.2

2 files

25.1

2 files

24.4

2 files

24.3

2 files

24.2

2 files

24.1

2 files

23.5

2 files

23.4

2 files

23.3

2 files

23.2

2 files

23.1

2 files

22.1

2 files

21.3

2 files

21.2

1 file

21.1

2 files

4.0.0

2 files

3.0.0

2 files

2.2.1

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.0

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

0.2.1

1 file

0.2.0

1 file

0.1.0

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page