在Django/Wagtail中设置默认标记

2024-10-03 09:19:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望能够使用标记管理器设置默认标记的列表

city_region_tags = TaggableManager(through=CityRegionSnippetTag, blank=True)

{}是-

class CityRegionSnippetTag(TaggedItemBase):
    content_object = models.ForeignKey(
        'CityRegionSnippet',
        on_delete=models.CASCADE,
        related_name='tagged_city_region'
    )

理想情况下,我会传递一个默认标签列表,例如。 tag_list = ['Spatial Patterns', 'Functional dynamics', 'Social-eco dynamics', 'Global-local dynamics']等等

有办法做到这一点吗

我在这里查看了自定义标记,但似乎并不是我想要做的事情——(https://django-taggit.readthedocs.io/en/latest/custom_tagging.html#

表单中标签的文档显示了标签在列表中的外观,但这是在用户输入之后。我希望能够在用户从tag_list-(https://django-taggit.readthedocs.io/en/latest/forms.html#tags-in-forms)到达之前将这些标记放入


Tags: djangohttps标记city列表modelstagreadthedocs