组织django标记标签或为标签分配属性? [英] Organizing django-tagging tags or assigning properties to tags?
问题描述
我想对我的标签进行分类。以下是我现在的标签示例:
I'd like to categorize my tags. Here's an example of the tags I have now:
css,internet-explorer,firefox,floats
每个都是单独的标签(总共4个)。我想将 internet-explorer
和 firefox
标签标记为浏览器。 django-tagging
提供了某种方式来执行此操作,还是必须手动编辑模式?
Each of those are separate tags ( 4 in total obviously ). I would like to mark the internet-explorer
and firefox
tags as browsers. Does django-tagging
offer some sort of way for doing this or do I have to manually edit the schema?
我真的不在乎我是不是要标记标签,或者添加一个新列到标签
表中,取决于插件的最简单方法。 >
I really don't care if I have to either tag tags or add a new column to the tags
table, whichever is the easiest way in accordance with the plugin.
推荐答案
有趣的是,我也遇到这个问题,并解决了这个问题。
我不想混淆django标记代码,因为如果我以后升级会很痛苦,所以我做了一个名为taggingtools的新模块。标签工具用于在管理界面中对标签和自动完成进行分组。对于分组我做了一个名为TagGroup的新模型,这个模型只是一个名字。 (例如浏览器)。我还添加了一些功能来返回该组的标签。然后,我将浏览器的标签添加到浏览器标签组。这样我可以说我想要所有的浏览器标签为某个数据库对象。很容易做到这一点,但如果可以等待,我可以检查我是否可以开源,这样您和他人就不必自己构建它。
Interesting, I came across this problem as well and solved it like this. I don't want to mess with the django-tagging code because it will be a pain if I wish to upgrade afterwards, so I made a new module called taggingtools. Taggingtools is for grouping tags and autocompletion in the admin interface. For the grouping I made a new model named TagGroup, this model just has a name. (for Example browsers). I also added some functions to return the tags for that group. I then added the tags for Browsers to the Browsers TagGroup. This way I can say I want all the browser tags for a certain database object. It's easy to make this, but if you can wait I can check if I can opensource it so you and others don't have to build it yourself.
这篇关于组织django标记标签或为标签分配属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!