django taggit标记的django管理助手类

django-taggit-helpers的Python项目详细描述


django-taggit-helpers使使用与django-taggit标记关联的模型的管理页更容易。

github上的源代码位于mfcovington/django-taggit-helpers。有关django-taggit的信息可在GitHubRead the Docs上找到。

django-taggit-helpers与python 2.7+/3.2+和django 1.7+兼容。

Installation

pypi

pip install django-taggit-helpers

github(开发分支)

pip install git+http://github.com/mfcovington/django-taggit-helpers.git@develop

Configuration

settings.py

中将taggit_helpers添加到INSTALLED_APPS
INSTALLED_APPS=(...'taggit','taggit_helpers',)

Helper Classes

^{tt5}$

显示(和排序)与标记项关联的taggit标记数。

fromtaggit_helpersimportTaggitCounter# For Django 1.9+, use this instead:# from taggit_helpers.admin import TaggitCounterclassMyModelAdmin(TaggitCounter,admin.ModelAdmin):# TaggitCounter before ModelAdminlist_display=(...'taggit_counter',)

注意:当前,TaggableManager()字段必须命名为tags

注意:若要避免过度计数,请设置distinct=True,如果要用Count()

queryset.annotate(m2m_field_count=Count('m2m_field',distinct=True))

^{tt6}$

仅按当前模型的taggit标记筛选记录。 标签按名称的字母顺序排列。

fromtaggit_helpersimportTaggitListFilter# For Django 1.9+, use this instead:# from taggit_helpers.admin import TaggitListFilterclassMyModelAdmin(admin.ModelAdmin):list_filter=[TaggitListFilter]

^{tt7}$

将taggit标记的堆叠内联添加到管理。 标签按名称的字母顺序排列。

fromtaggit_helpersimportTaggitStackedInline# For Django 1.9+, use this instead:# from taggit_helpers.admin import TaggitStackedInlineclassMyModelAdmin(admin.ModelAdmin):inlines=[TaggitStackedInline]

^{tt8}$

将taggit标记的表格内联添加到admin。 标签按名称的字母顺序排列。

fromtaggit_helpersimportTaggitTabularInline# For Django 1.9+, use this instead:# from taggit_helpers.admin import TaggitTabularInlineclassMyModelAdmin(admin.ModelAdmin):inlines=[TaggitTabularInline]

Upgrading existing projects to Django 1.9+

应用程序加载在django 1.9中进行了重构。要使django 1.7/1.8应用程序django 1.9与django-taggit-helpers兼容,请在应用程序目录中运行以下shell命令。

find . -name '*.py'| xargs perl -i -pe 's/from taggit_helpers import/from taggit_helpers.admin import/'

感谢jpicinspiration为这个片段!

Issues

如果您遇到任何问题或想要请求功能,请在github上create an issue

版本0.1.4

Revision history

0.1.4 2015年12月4日

  • 添加django 1.9兼容性

0.1.3 2015年11月30日

  • 需要python 2.7+/3.2+
  • 添加来自django sf meetup lightning talk的幻灯片

0.1.2 2015年6月14日

  • 添加django 1.8兼容性

0.1.1 2015年6月11日

  • taggit_count重命名为taggit_counter

0.1.0 2015年6月10日

  • django taggit标记的django管理助手类
    • TaggitCounter
    • TaggitListFilter
    • TaggitStackedInline
    • TaggitTabularInline

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

推荐PyPI第三方库


热门话题
java InputStream对象在声明后关闭   java未定义名为“transactionManager”的bean重命名transactionManager   java“jar”命令何时会拒绝将类添加到java中。jar文件?   java JPA标准依赖WHERE子句   安卓中从SD卡读取文本文件时出现java错误   java直接启用类似位置的权限   使用@WebMvcTest和Mockito-BDDMockito对SpringBoot-RestController进行java测试   java JSESSIONID存储在哪里?   java jtextarea鼠标事件覆盖容器鼠标事件   java DRL无法解析动态加载的类   java是从一个方法返回多个对象的最简单方法   java自定义按钮/编辑框是否不可见?   java GUI如何在保存用户输入的同时在面板或框架之间切换   swing Java自定义JSlider不会更新   GridBagLayout中的java超过1个JPanel   java从ProjectReactor中的flux中采样除第一个元素外的所有元素   Java泛型和泛型类型   Java代码生成宽指令的jvm