Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zostera/django-icons
Icons for Django
https://github.com/zostera/django-icons
django icons
Last synced: 2 days ago
JSON representation
Icons for Django
- Host: GitHub
- URL: https://github.com/zostera/django-icons
- Owner: zostera
- License: bsd-3-clause
- Created: 2017-06-15T12:59:55.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-12-13T10:48:12.000Z (24 days ago)
- Last Synced: 2024-12-27T19:11:57.147Z (9 days ago)
- Topics: django, icons
- Language: Python
- Homepage: http://django-icons.readthedocs.io/en/latest/index.html
- Size: 614 KB
- Stars: 76
- Watchers: 5
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# django-icons
[![Tests](https://github.com/zostera/django-icons/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/zostera/django-icons/actions?query=workflow%3Atest+branch%3Amain)
[![Coverage Status](https://coveralls.io/repos/github/zostera/django-icons/badge.svg?branch=main)](https://coveralls.io/github/zostera/django-icons?branch=main)
[![Latest PyPI version](https://img.shields.io/pypi/v/django-icons.svg)](https://pypi.python.org/pypi/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
- [PyPI (django-icons)](https://pypi.python.org/pypi/django-icons)
- [Documentation](https://django-icons.readthedocs.io/en/latest/)
- [Bug tracker](http://github.com/zostera/django-icons/issues)## Installation
Install using pip.
```shell
pip install django-icons
```In your `settings.py`, add `django_icons` to `INSTALLED_APPS` and define an icon.
```python
INSTALLED_APPS = (
# ...
"django_icons",
# ...
)DJANGO_ICONS = {
"ICONS": {
"edit": {"name": "fa-solid fa-pencil"},
},
}
```Render an icon in a Django template.
```djangotemplate
{% load icons %}{% icon 'edit' %}
```This will generate the FontAwesome 6 pencil icon in regular style.
```html
```Add extra classes and attributes to your predefined icon.
```djangotemplate
{% load icons %}
{% icon 'edit' extra_classes='fa-2xs my-extra-class' title='Update' %}
```These will be added to the HTML output.
```html
```## Requirements
This package requires a combination of Python and Django that is currently supported.
See "Supported Versions" on .
## Local installation
### Local installation
This package uses [uv](https://github.com/astral-sh/uv) and [just](https://github.com/casey/just).
To clone the repository and install the requirements for local development:
```console
git clone git://github.com/zostera/django-icons.git
cd django-icons
just bootstrap
```### Running the demo
You can run the example app:
```shell
just example
```### Running the tests
The test suite requires [tox](https://tox.readthedocs.io/) to be installed. Run the complete test suite like this:
```shell
tox
```Test for the current environment can be run with the Django `manage.py` command.
```shell
just test
```## Origin
Our plans at Zostera for an icon tool originate in . We isolated this into a Font Awesome tool in . 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 usersThis is how we came to write and use `django-icons`.