Django 4 compatible + FA 6
This is a fork of https://github.com/BenjjinF/django-fontawesome-5 and I made some minor changes so this is compatible with my Django 4 Projects and makes use of Fontawesome 6.0.0
I consider renaming this to django-fontawesome-6 in the near future and to provide a new python module.
Semi-Maintained
This is a best-effort fork, I try to keep it up-to-date but can't promise any further development.
django-fontawesome-6
A utility for using icons in models, forms, and templates and supports Django 4.0.
Migration guide from django-fontawesome
- Remove all occurences of {% fontawesome_stylesheet %}
- Replace {% load fontawesome %} with {% load fontawesome_6 %}
- Replace '{% fontawesome_icon' with '{% fa6_icon'
- Replace iconnames, for example "bell" needs to be replaced with "bell fas" and "linedin-square" with "linkedin fab"
Installation / Usage
pipenv install django-fontawesome-6
Add 'fontawesome_6' to your installed INSTALLED_APPS:
INSTALLED_APPS = (
...
'fontawesome_6',
)
Import and use IconField:
from fontawesome_6.fields import IconField
class Category(models.Model):
...
icon = IconField()
Include Static Files
{% load fontawesome_6 %}
<head>
{% fontawesome_6_static %}
...
</head>
Settings
You can configure django-fontawesome to use another release/source/cdn by specifying::
FONTAWESOME_6_CSS = URL or None
default: 'fontawesome_6/css/django-fontawesome.css'
FONTAWESOME_6_CSS_ADMIN = URL or path
default: None
FONTAWESOME_6_ICON_CLASS = 'default' or 'semantic_ui'
default: 'default'
FONTAWESOME_6_PREFIX = 'custom_prefix'
default: 'fa'
Rendering
You can do a simple render in your template like this:
{% for category in categories.all %}
{% if category.icon %}
{{ category.icon.as_html }}
{% endif %}
{% endfor %}
Default Renderer
Or you can use the {% fa6_icon %} template tag.
{% fa6_icon 'github' 'fab' %}
Positional arguments: icon (required), style_prefix (default: 'fas')
Key word arguments:
- class
extra custom classes - color
CSS Color Names - border
boolean - fixed_width
boolean - flip
horizontalvertical
- li
boolean - pull
leftright- pulse
boolean - rotate
integer - size
fa-xsfa-smfa-lgfa-2xfa-3xfa-5xfa-7xfa-10x
- spin
boolean - title
string
Semantic UI Renderer
Or you can use the {% fa6_icon %} template tag.
{% fa6_icon 'check' %}
Required positional arguments: icon
Key word arguments:
- class
extra custom classes - bordered
boolean - circular
boolean - colored
Semantic UI Colors - disabled
boolean - fitted
boolean - flipped
horizontalvertical
- inverted
boolean - link
boolean - loading
boolean - rotated
clockwisecounterclockwise- pulse
boolean - rotate
integer - size
fa-xsfa-smfa-lgfa-2xfa-3xfa-5xfa-7xfa-10x
- title
string
Credit
Credit to https://github.com/redouane for the original
Also credit to https://github.com/BenjjinF for the django-fontawesome-5 version
Changes
- refactored functions and classes
- Updated for use with Font Awesome 6
- Made compatible with Django 4
- forked from https://github.com/BenjjinF/django-fontawesome-5
- Updated for use with Font Awesome 5
- Removed PyYAML, Select2, and jQuery as dependencies
- Static files tag includes static dependencies for use outside admin
- Moved rendering logic to renderers
Release files for django-fontawesome-6 1.0.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-fontawesome-6-1.0.0.0.tar.gz | 1.9 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_fontawesome_6-1.0.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.8 MB
Release files / django-fontawesome-6-1.0.0.0.tar.gz
| Download URL | django-fontawesome-6-1.0.0.0.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ecdf42a1145b20d8168cbd2c7e372d10634a8cce0670ea4f571c80186d3936e7
|
|
BLAKE2b-256 checksum How to use checksums |
377949933b7cb91f3b1f6fbd5ff60031020ebeb796203b04bcf0a4ad7549f0c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12
|
Release files / django_fontawesome_6-1.0.0.0-py3-none-any.whl
| Download URL | django_fontawesome_6-1.0.0.0-py3-none-any.whl |
|---|---|
| Size | 1.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d470ce335dfda2db41bef31f70ceb4e5bab0e256cc8c6d7de9f2d267b0d74ce9
|
|
BLAKE2b-256 checksum How to use checksums |
e1e59bb235a51bbd78310c4d9d6024e98b7f456960911727a30482e67cd84c69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12
|