GithubHelp home page GithubHelp logo

realorangeone / django-fontawesome-6 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saschaludwig/django-fontawesome-6

0.0 2.0 0.0 5.93 MB

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

License: BSD 2-Clause "Simplified" License

JavaScript 24.98% Python 70.40% HTML 1.79% SCSS 2.82%

django-fontawesome-6's Introduction

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 renamed this to repo to "django-fontawesome-6" 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.

Clip of dropdown

Migration guide from django-fontawesome

  1. Remove all occurences of {% fontawesome_stylesheet %}
  2. Replace {% load fontawesome %} with {% load fontawesome_6 %}
  3. Replace '{% fontawesome_icon' with '{% fa6_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-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
    • 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 {% 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
    • 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
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

django-fontawesome-6's People

Contributors

atiberghien avatar benjamin-t-frost avatar bittner avatar dersphere avatar jelouemoncampingcar avatar jimmy927 avatar mitzam avatar mjamro avatar redouane avatar saschaludwig avatar saty9 avatar sidneijp avatar thijstriemstra avatar zoidyzoidzoid avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.