GithubHelp home page GithubHelp logo

yangyubo / django-taggit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jazzband/django-taggit

4.0 2.0 0.0 284 KB

django-taggit app with all tags in lowercase and Chinese comma support

Home Page: http://django-taggit.readthedocs.org/

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

django-taggit's Introduction

django-taggit

和最初 alex/django-taggit 的区别

  1. 增加 TAGGIT_FORCE_LOWERCASE = True 配置项,启用后所有标签都会转换成小写对待;
  2. 只认中、英文逗号(,)作为标签的分割符,空格在任何情况下都被认为是标签的一部分。

一般使用方法

django-taggit 是一个简单易用的 Django 标签 app。把 "taggit" 加到在你项目中的 INSTALLED_APPS 中, 然后为你的 model 增加 TaggableManager 就完工了 :

from django.db import models

from taggit.managers import TaggableManager

class Food(models.Model):
    # ... fields here

    tags = TaggableManager()

接下来你便可以按如下方式使用 API:

>>> apple = Food.objects.create(name="apple")
>>> apple.tags.add("red", "green", "delicious")
>>> apple.tags.all()
[<Tag: red>, <Tag: green>, <Tag: delicious>]
>>> apple.tags.remove("green")
>>> apple.tags.all()
[<Tag: red>, <Tag: delicious>]
>>> Food.objects.filter(tags__name__in=["red"])
[<Food: apple>, <Food: cherry>]

Tags 将会自动显示在表单和后台 admin 中。

django-taggit 依赖 Django 1.1 或更高版本.

For more info checkout out the documentation. And for questions about usage or development you can contact the mailinglist.

django-taggit's People

Contributors

alex avatar bfirsh avatar carljm avatar fcurella avatar frankwiles avatar gvangool avatar idlesign avatar jezdez avatar jobscry avatar mcroydon avatar robhudson avatar shacker avatar soviut avatar

Stargazers

 avatar  avatar  avatar  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.