Skip to main content

A fork of a utility for using icons in models, forms, and templates.

Project description

django-fontawesome-5

A utility for using icons in models, forms, and templates. Does support Django 3.0, which django-fontawesome will not.

Clip of dropdown

Migration guide from django-fontawesome

  1. Remove all occurences of {% fontawesome_stylesheet %}
  2. Replace {% load fontawesome %} with {% load fontawesome_5 %}
  3. Replace '{% fontawesome_icon' with '{% fa5_icon'
  4. Replace iconnames, for example "bell" needs to be replaced with "bell fas" and "linedin-square" with "linkedin fab"

Installation / Usage

pipenv install django-fontawesome-5

Add 'fontawesome_5' to your installed INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'fontawesome_5',
)

Import and use IconField:

from fontawesome_5.fields import IconField

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

Include Static Files

{% load fontawesome_5 %}

<head>
  {% fontawesome_5_static %} 
  ...
</head>

Settings

You can configure django-fontawesome to use another release/source/cdn by specifying::

FONTAWESOME_5_CSS = URL or None
    default: 'fontawesome_5/css/django-fontawesome.css'
FONTAWESOME_5_CSS_ADMIN = URL or path
    default: None
FONTAWESOME_5_ICON_CLASS = 'default' or 'semantic_ui' 
    default: 'default'
FONTAWESOME_5_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 {% fa5_icon %} template tag.

{% fa5_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
    • horizontal
    • vertical
  • li boolean
  • pull
  • left
  • right
  • pulse boolean
  • rotate integer
  • size
    • fa-xs
    • fa-sm
    • fa-lg
    • fa-2x
    • fa-3x
    • fa-5x
    • fa-7x
    • fa-10x
  • spin boolean
  • title string

Semantic UI Renderer

Or you can use the {% fa5_icon %} template tag.

{% fa5_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
    • horizontal
    • vertical
  • inverted boolean
  • link boolean
  • loading boolean
  • rotated
  • clockwise
  • counterclockwise
  • pulse boolean
  • rotate integer
  • size
    • fa-xs
    • fa-sm
    • fa-lg
    • fa-2x
    • fa-3x
    • fa-5x
    • fa-7x
    • fa-10x
  • title string

Credit

Credit to https://github.com/redouane for the original ~

Changes

  • 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

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-fontawesome-5-renewed-1.0.19.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_fontawesome_5_renewed-1.0.19-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

Details for the file django-fontawesome-5-renewed-1.0.19.tar.gz.

File metadata

File hashes

Hashes for django-fontawesome-5-renewed-1.0.19.tar.gz
Algorithm Hash digest
SHA256 438555175146dd64e9e2b01cfdd165a2bfddb6ae9eb3ec4bdda8f2999f50982d
MD5 4c794247d92dd5263568bf94fdd980dc
BLAKE2b-256 bde1337c422a7cbb4c21b1e196d6a7350d54555680cff4c91ca74778601fa342

See more details on using hashes here.

File details

Details for the file django_fontawesome_5_renewed-1.0.19-py3-none-any.whl.

File metadata

File hashes

Hashes for django_fontawesome_5_renewed-1.0.19-py3-none-any.whl
Algorithm Hash digest
SHA256 c481aa546be6b5a8fee1d81e3851418bbb601fe110a88125c6527f718b4b91a2
MD5 8adf984becc22650f6e9be060b7b8fbc
BLAKE2b-256 11b727dc42fa71739132aa2f7937f47791162d340f81807e642eadc3b431751f

See more details on using hashes here.

Supported by

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