Skip to main content

A utility for using icons in models and forms.

Project description

django-font-icons

A utility for using icons in models and forms. You can also disable icons so they will no show in the select.

It uses selectr for filtering of the icons.

Installation / Usage

pip install django-font-icons

Add 'font_icons' to your installed INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'font_icons',
)

Import and use IconForeignKeyField:

from font_icons.models import IconForeignKeyField

class Category(models.Model):
    ...
    icon = IconForeignKeyField()

Add Fontawesome js and/or css yourself. We do not provide a default version.

admin/base_site.html

{% block extrastyle %}
    {{ block.super }}
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
    <link href="https://unpkg.com/mobius1-selectr@latest/dist/selectr.min.css" rel="stylesheet" type="text/css">
    <script src="https://unpkg.com/mobius1-selectr@latest/dist/selectr.min.js" type="text/javascript"></script>
{% endblock %}

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 %}

Changes

  • Add the fontawesome 5 Free icons. (manage.py loadfontawesome5_free)
  • Support for fontawesome 5 Pro and fontawesome 4.7 (No management command to load all the icons yet.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-font-icons-1.0.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

django_font_icons-1.0.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file django-font-icons-1.0.0.tar.gz.

File metadata

  • Download URL: django-font-icons-1.0.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for django-font-icons-1.0.0.tar.gz
Algorithm Hash digest
SHA256 94030a364bdddd1abe2621371289acc89840603ab2d5402eac7566db3aa73f38
MD5 ab5918af1330caa8ed810b540832b511
BLAKE2b-256 2035644ed07cb3166bb82bc987b808c5520a6d0b6ca198338e4f67dc4419bbde

See more details on using hashes here.

File details

Details for the file django_font_icons-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: django_font_icons-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for django_font_icons-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 258d76e68ddac8be322e1af819cb37422200b91e7e7819c4a733191ad5c2e8a8
MD5 d0c0361055353a8e8fff8f513a333f9e
BLAKE2b-256 df02ec2572a598c1132124a834b518a73a4b630c87aae245b0db7ca33bc0aa3a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page