Icons for Django
Project description
django-icons
Icons for Django
Why should I use this?
- 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 out of the box.
- Add other (custom) icon sets by subclassing a renderer.
How do I use this?
Define an icon in your settings.py
, for example like this:
DJANGO_ICONS = {
"ICONS": {
"edit": {"name": "far fa-pencil"},
},
}
The basic usage 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 like this:
{% load icons %}
{% icon 'edit' extra_classes='fa-fw my-own-icon' title='Update' %}
This will generate:
<i class="far fa-pencil fa-fw my-own-icon" title="Update"></i>
Requirements
This package requires a Python 3.6 or newer and Django 2.2 or newer.
The combination must be supported by the Django Project. See "Supported Versions" on https://www.djangoproject.com/download/.
Local installation
django-icons
adopts Poetry to manage its dependencies. This is the recommended way to do a local installation for development or to run the demo.
Assuming Python>=3.6 is available on your system, the development dependencies are installed with Poetry as follows:
$ git clone git://github.com/zostera/django-icons.git
$ cd colour
$ poetry install
Running the demo
You can run the small demo app that is part of the test suite:
poetry 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 (virtual) environment can be run with the Django manage.py
command. If you need to do this, you will need to have an understanding of Python virtual environments. Explaining those is beyong the scope of this README.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_icons-2.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e90262733505e2592e2ca1311ff59a0da7fd7a71c021530c6d8258a95a76444 |
|
MD5 | cf3affffc6bfa702fb90befde9999c7a |
|
BLAKE2b-256 | 232c01ca69053c65f2bd322425d911b8f95582b18860042210385a2591db6255 |