Skip to main content

Icons for Django

Project description

django-icons

CI Coverage Status Latest PyPI version

Icons for Django

  • 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.

More information

Installation

Install using pip.

pip install django-icons

In your settings.py, add django_icons to INSTALLED_APPS and define an icon.

INSTALLED_APPS = (
    # ...
    "django_icons",
    # ...
)

DJANGO_ICONS = {
    "ICONS": {
        "edit": {"name": "fa-solid fa-pencil"},
    },
}

Render an icon in a Django 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>

Requirements

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

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

Local installation

Local installation

This package uses uv and just.

To clone the repository and install the requirements for local development:

git clone git://github.com/zostera/django-icons.git
cd django-icons
just bootstrap

Running the demo

You can run the example app:

just example

Running the tests

The test suite requires tox to be installed. Run the complete test suite like this:

tox

Test for the current environment can be run with the Django manage.py command.

just test

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.

Project details


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.1.tar.gz (26.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.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_icons-26.1.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","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.1.tar.gz
Algorithm Hash digest
SHA256 7596f64cb3079b45ae0d946e1e193414838118fdbd9511f96f01fac52287b305
MD5 9a369d85eaff3c015b9dc275c9f60c22
BLAKE2b-256 894169b56b30cd09f9601729b173d02da7aa61db8c3e14508cb89e14885bd733

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_icons-26.1-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 930ae73a6cde94a1e4a9479635eb785bf9b96fa7147511ca62957ae36376b077
MD5 c236234759d65e90214cf84f08d2480a
BLAKE2b-256 38f6778bf8c83781073e2cf6899a5cf07b5b44c325abc7bee4af6783c6088c5d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page