django jquery tags input是一个django字段和小部件包装器,它为“manytomanyfield”和“foreignkey”字段添加了一个易于使用的界面,以自动完成标记的形式,并可以选择实时创建新的链接项。

django-tags-input的Python项目详细描述


概述

https://travis-ci.org/WoLpH/django-tags-input.svg?branch=masterhttps://coveralls.io/repos/WoLpH/django-tags-input/badge.svg?branch=master

django标记输入是一个模块,它为您提供django中xoxco jquery标记输入库的修改版本。

结果是一个非常漂亮的界面与标签和自动完成,可以选择自动创建新的项目时,他们失踪。

django标记输入最有用的特性之一是,它按照输入的顺序存储元素。

因此,如果您将b,a,c插入数据库,它将按您输入的方式返回它:b,a,c

https://raw.githubusercontent.com/WoLpH/django-tags-input/master/docs/example.png

如何安装

安装这个模块只需要几分钟。

目前Django1.8、1.9、1.10和1.11与Python2.7、3.2、3.3、3.4、3.5、3.6和PyPy一起支持和测试。

对于django 1.4、django 1.5、django 1.6和django 1.7以及 Python2.6和2.7。python 3.2、3.3和3.4。pypy和pypy3版本2.1.0可以 被利用。

  1. 安装模块本身

    pip install django-tags-input

    # or

    easy_install django-tags-input

  2. tags_input添加到djangosettings.py中的INSTALLED_APPS设置中。

    Example:

    INSTALLED_APPS=(# ... your other installed apps'tags_input',)
  3. 将映射添加到settings.py文件:

    Example:

    TAGS_INPUT_MAPPINGS={'some_app.SomeKeyword':{'field':'some_field',},'some_app.SomeOtherKeyword':{'fields':('some_field','some_other_field'),},'some_app.SomeSortedKeyword':{'field':'some_field','ordering':['some_field','some_other_field',],'filters':{'some_field__istartswith':'a',},'excludes':{'some_field__iexact':'foobar',},},'some_app.SomeCreateableKeyword':{'field':'some_field','create_missing':True,},}
  4. tags_inputurl添加到urls.py

    Example:

    fromdjango.confimporturlsurlpatterns=patterns('',url(r'^tags_input/',include('tags_input.urls',namespace='tags_input')),# ... other urls ...)

管理用法

fromdjango.contribimportadminimportmodelsfromtags_inputimportadminastags_input_adminclassYourAdmin(tags_input_admin.TagsInputAdmin):#Optionally specify which ManyToMany fields are to be used for tagging#Or define a get_tag_fields() methodtag_fields=["some_field"]admin.site.register(models.YourModel,YourAdmin)

快速启动

要测试项目,只需克隆存储库,请安装并运行示例:

# mkvirtualenv is part of virtualenvwrapper, using a regular virtualenv, pyvenv or pipenv is also possible
# Or even without any type of virtualenv at all
mkvirtualenv django-tags-input
git clone https://github.com/WoLpH/django-tags-input.git
# Tested with up to Django 2.1
pip install django
pip install -e 'django-tags-input[tests]'cd django-tags-input/example
python manage.py runserver

现在您可以转到http://localhost:8000/admin/并使用用户名和 密码adminadmin分别。

在此之后,您可以尝试通过spamadmin添加一些额外的foo对象 这里:http://localhost:8000/admin/autocompletionexample/spam/2/

注意,为了测试 在破碎环境中的行为。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java爬虫获取外部网站搜索结果   java Bluestack未连接到eclipse   java如何从ConstraintViolationException Hibernamte获取数据库字段名   HttpResponse HttpResponse=httpClient引发java运行时错误。执行(httpPost);   Jama中矩阵的java点积和叉积   java有什么方法可以唯一地识别可扩展设备吗?   java我需要用*来写我的名字,但我不断遇到一个错误,我对编码很陌生   java变量是在内部类中访问的。需要被宣布为最终决定。但我不想宣布最终结果   java如何缩短base64图像字符串,Android?   JavaSpringMVC:计划方法不自动触发   图形学习Java 2D API的好资源是什么?   如何在java中对方法进行排队   java JavaFX多行   java Selenium无法在[链接]上找到基于CSS元素的密码字段元素http://www.cartasi.it/gtwpages/index.jsp   Java中的equals()和hashCode()契约   软删除情况下的java Hibernate二级缓存   java为什么这段代码要两次调用这些方法?