Code Monkey home page Code Monkey logo

django-colortag's Introduction

Django colortag

Tools to help building data tagging models. Used for example in A+ and MOOC-Jutut projects to tag feedbacks or users with colored tags. Project builds on top of Django and django-html5-colorfield.

Installation and usage

Requirements:

Add stuff to requirements.txt:

git+https://github.com/Aalto-LeTech/[email protected]#egg=django-colortag==2.0.0

Install them with pip install --process-dependency-links -r requirements.txt (--process-dependency-links is needed, if you don't have js-jquery-toggle in requirements.txt as it's not disributed via pypi).

Add relevant stuff to INSTALLED_APPS:

  • js_jquery_toggle, if you are not using app dependency loading
  • django_colortag

Add something like this to your html header:

<!-- TODO: load bootstrap v3 css -->
<!-- TODO: load jquery -->
<!-- jquery toggle is used by colortag js -->
{% include 'jquery_toggle.head.html' %}
<!-- defines django_colortag_choice js function -->
{% include 'django_colortag.head.html' %}

For bootstrap tooltips to work, you need to do something like this:

$(function() {
  $('.colortag[data-toggle="tooltip"]').tooltip();
  $('.colortag-choice').each(django_colortag_choice); /* only needed if you use ColortagChoiceFilter, ColortagChoiceField or ColortagSelectMultiple */
});

You can render colortag in your templates like this:

{{ tag.render_as_button }}
<!-- or -->
{% load colortag %}
{{ tag|colortag_button }}

For tags to exists, define model like this:

from django_colortag.models import ColorTag

class ItemTag(ColorTag):
    items = models.ManyToManyField(Items, related_name='tags')

You can use colortags in filters like this:

import django_filters
from django_colortag.filters import ColortagChoiceFilter

class TagFilter(django_filters.FilterSet):
    tags = ColortagChoiceFilter()

django-colortag's People

Contributors

jrp6 avatar markkuriekkinen avatar raphendyr 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.