Skip to main content

Icons for Django

Project description

django-icons

CI Coverage Status Latest PyPI version Any color you like

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

Define an icon in your settings.py.

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

Render an icon in a Django template.

{% load icons %}
{% icon 'edit' %}

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

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

Add extra classes and attributes to your predefined icon.

{% load icons %}
{% icon 'edit' extra_classes='fa-fw my-own-icon' title='Update' %}

These will be added to the HTML output.

<i class="far fa-pencil fa-fw my-own-icon" 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

This section assumes you know about local Python versions and virtual environments.

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

$ git clone git://github.com/zostera/django-icons.git
$ cd django-icons
$ pip install -U pip -r requirements-dev.txt

Running the demo

You can run the example app:

cd example && run python manage.py runserver

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.

python manage.py 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 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
  • And 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.

Files for django-icons, version 4.0.0
Filename, size File type Python version Upload date Hashes
Filename, size django_icons-4.0.0-py3-none-any.whl (46.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-icons-4.0.0.tar.gz (42.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page