我正在研究Wagtail,在设置标签时遇到以下问题。
我添加了以下模型:
@register_snippet
class BlogTag(TagBase):
free_tagging = False
name = models.CharField(max_length=25, unique=True)
slug = models.SlugField(max_length=255, unique=True, blank=True)
class Meta:
verbose_name = "blog tag"
verbose_name_plural = "blog tags"
class TaggedBlog(ItemBase):
tag = models.ForeignKey(
BlogTag, related_name="tagged_blogs", on_delete=models.CASCADE
)
content_object = ParentalKey(
'home.BlogPage',
on_delete=models.CASCADE,
related_name='tagged_items'
)
我启用了设置 TAGGIT_CASE_INSENSITIVE = True。
但是,当用户在创建页面时填写标签时,仍然会考虑大小写 - 如果用户输入小写单词,下拉列表中的选项不会出现。
这是模型,如果重要的话:
class BlogPage(Page):
tags = ClusterTaggableManager(through=TaggedBlog, blank=True)
date = models.DateField("Мы это написали:")
author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True, related_name='blog_pages')
body = StreamField([
('heading', blocks.CharBlock(form_classname="title", label="Заголовок")),
('paragraph', blocks.RichTextBlock(label="Текст")),
('image', ImageChooserBlock(label="Изображение")),
('quote', blocks.BlockQuoteBlock(min_length='20', label="Цитата")),
('media', EmbedBlock(label="Ссылка на видео")),
], verbose_name='Содержимое')
content_panels = Page.content_panels + [
FieldPanel('date'),
FieldPanel('body'),
FieldPanel('slug', permission='superuser'),
FieldPanel('tags'),
]
edit_handler = TabbedInterface([
ObjectList(content_panels, heading='Центр управления постами'),
ObjectList(Page.promote_panels, heading='Promote', permission='superuser'),
])
def _get_unique_slug(self):
slug = slugify(self.title)
unique_slug = slug
num = 1
while Page.objects.filter(slug=unique_slug).exists():
unique_slug = '{}-{}'.format(slug, num)
num += 1
return unique_slug
def save(self, *args, **kwargs):
self.slug = self._get_unique_slug()
super().save(*args, **kwargs)
请告诉我我做错了什么
我启用了设置 TAGGIT_CASE_INSENSITIVE = True
您描述的问题与 Django Taggit 中的这个未解决问题相同吗? https://github.com/jazzband/django-taggit/issues/448