Django taggit,使用自定义标记名 [英] Django taggit, using a custom tagname
问题描述
我已经设置了django-taggit,并且工作正常,所有标签都列在admin中的标签下.
但是,我现在想将我的标签分为两组,英文标签和西班牙标签.
这就是我从文档此处所获得的:
EnTagged(TagBase)类:类Meta:verbose_name =英文标签"verbose_name_plural =英文标签"类EnglishTags(GenericTaggedItemBase):标签= models.ForeignKey(EnTagged)类Blog(models.Model):en_tags = TaggableManager(空白=正确,通过= EnglishTags)
(编辑)现在标记可以正常工作,但是标记位于正确的数据库表中,但是我在管理员中看不到我的自定义标记-如何在管理员中显示我的自定义标记?>
我要去哪里错了?
创建一个 admin.py
文件并将其放入您的应用程序中,并在其中添加以下行:
导入管理员从.models import EnTaggedadmin.site.register(已标记)
I've set up django-taggit and it's working fine, all tags are listed under tags in admin.
However, I now want to separate my tags into 2 groups, english tags, and spanish tags.
This is what I have, from the documentation here:
class EnTagged(TagBase):
class Meta:
verbose_name = "English Tag"
verbose_name_plural = "English Tags"
class EnglishTags(GenericTaggedItemBase):
tag = models.ForeignKey(EnTagged)
class Blog(models.Model):
en_tags = TaggableManager(blank=True, through=EnglishTags)
(Edit) now tagging works fine, but in temrs of the tags being in the right db tables, but I don't see my custom tags in the admin - how do i show my custom tags in the admin?
Where am I going wrong?
Create a admin.py
file and put it inside your app and add following lines in it:
from django.contrib import admin
from .models import EnTagged
admin.site.register(EnTagged)
这篇关于Django taggit,使用自定义标记名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!