Icons for Django
Project description
django-icons
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
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 -e .
$ 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 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
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
File details
Details for the file django_icons-24.4.tar.gz
.
File metadata
- Download URL: django_icons-24.4.tar.gz
- Upload date:
- Size: 30.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ae699e22cfc6a80a62eaa267a1d345f2c79adfa6f68f7f67a0316fefac977b3 |
|
MD5 | a93b6adcaef4733a9b905db4144d6efe |
|
BLAKE2b-256 | 36dac34386f12d2aed9e3b460a18b0003811e7c38e9cb0828ba90ac068ec079c |
File details
Details for the file django_icons-24.4-py3-none-any.whl
.
File metadata
- Download URL: django_icons-24.4-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6518bcf6554f0a3ebad5b5095c7cf929c251e96b9316de987203b1f00ac65951 |
|
MD5 | 485d4736b46da76746388ac912b9eb3b |
|
BLAKE2b-256 | 510cb80a98f5ba85e220894856fddf0876301bb68ec86175e2272baff660914b |