Coder Social home page Coder Social logo

raiderrobert / django-fontawesome Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redouane/django-fontawesome

0.0 2.0 0.0 1.2 MB

a django app that provides a couple of fontawesome/django related utilities

License: BSD 2-Clause "Simplified" License

Python 24.00% JavaScript 1.93% CSS 74.07%

django-fontawesome's Introduction

django-fontawesome

image

Downloads

License

django-fontawesome is a django app that provides a couple of fontawesome/django related utilities, namely:

  • an IconField to associate fontawesome icons with model instances
  • templatetags to render fontawesome icons

also included:

  • admin support for the IconField
  • fr locale translation

Requirements

  • PyYAML
  • Select2 (included)
  • JQuery (uses django's jquery in admin panel)

Settings

by default, django-fontawesome ships with/uses the lastest fontawesome release. you can configure django-fontawesome to use another release/source/cdn by using:

FONTAWESOME_CSS_URL # default uses locally shipped version at 'fontawesome/css/font-awesome.min.css'
FONTAWESOME_CSS_URL = '//cdn.example.com/fontawesome-min.css' # absolute url
FONTAWESOME_CSS_URL = 'myapp/css/fontawesome.min.css # relative url

you can also tell it the fontawesome prefix, which as of right now is 'fa', using:

FONTAWESOME_PREFIX # default is 'fa'

Installation / Usage

  1. Install via pip

` pip install django-fontawesome`

  1. add 'fontawesome' to your installed apps setting like this:

    INSTALLED_APPS = (
        ...
        'fontawesome',
    )
  2. import and use the iconfield:

    from fontawesome.fields import IconField
    
    
    class Category(models.Model):
        ...
        icon = IconField()

here's what the widget looks like in the admin panel:

admin-widget

  1. you can then render the icon in your template like this:

    {% for category in categories.all %}
        {% if category.icon %}
            {{ category.icon.as_html }}
        {% endif %}
    {% endfor %}
  2. django-fontawesome ships with two template tags, fontawesome_stylesheet and fontawesome_icon.
    • the former inserts a stylesheet link with a pre-configured href according to the FONTAWESOME_CSS_URL setting
    • the latter renders icons, and accepts the following optional keywords arguments: large, spin, fixed, li, border: (true/false), rotate: (90/180/270), title: (string)
    • you can also colorize an icon using the color='red' keyword argument to the fontawesome_icon template tag
    {% load fontawesome %}
    
    <head>
      {% fontawesome_stylesheet %} 
      ...
    </head>
    
    {% fontawesome_icon 'user' color='red' %}
    
    {% fontawesome_icon 'star' large=True spin=True %}
    
    <ul class="fa-ul">
       <li> {% fontawesome_icon 'home' rotate=90 li=True %} One</li>
    </ul>
  3. profit!!!

changelog

Jan 28, 2016

  • updated icon mapping file (icons.yml) for fontawesome 4.5.0
  • new keyword arg for fontawesome_icon template tag: title

Dec 17, 2015

  • Updated locally shipped fontawesome to 4.5.0
  • fontawesome_icon's output is now marked safe

Sep 11, 2015

  • Updated locally shipped fontawesome to 4.4.0

Feb 27, 2015

  • added two new keyword argument to the fontawesome_icon template tag, color and border
  • FONTAWESOME_PREFIX setting is now taken into account when rendering icons using the fontawesome_icon template tag

django-fontawesome's People

Contributors

dersphere avatar jelouemoncampingcar avatar raiderrobert avatar redouane 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.