小编elm*_*est的帖子

添加streamfield以在Wagtail中搜索索引

我很难将我的流场添加到wagtail搜索索引中.这会影响可用块或自定义块.

根据我在邮件列表中找到的内容,应该实现一个自定义块get_searchable_content,所有块都可以实现.

这是我想要索引的模型:

class BlogPage(Page):
    author = models.ForeignKey(User, on_delete=models.PROTECT)
    date = models.DateField("Post date")
    main_category = models.ForeignKey('blog.BlogCategory', related_name='main_category', default=1, on_delete=models.PROTECT)
    categories = ParentalManyToManyField('blog.BlogCategory', blank=True, related_name='categories')
    readtime = models.IntegerField(blank=True, null=True)
    subtitle = models.CharField(
        verbose_name=_('subtitle'),
        max_length=255,
        help_text=_("The page subtitle as you'd like it to be seen by the public - also the blog post teaser."),
    )
    body = StreamField([
        ('heading', general.TitleBlock()),
        ('paragraph', blocks.RichTextBlock()),
        ('image', general.FillImageChooserBlock()),
        ('subtitle', general.SubTitleBlock()),
        ('pullquote', general.PullQuoteBlock()),
        ('blockquote', general.BlockQuoteBlock()),
    ])
    cover = models.ForeignKey(
        'wagtailimages.Image',
        on_delete=models.PROTECT,
        related_name='+'
    )

    content_panels = …
Run Code Online (Sandbox Code Playgroud)

python django wagtail

3
推荐指数
1
解决办法
679
查看次数

标签 统计

django ×1

python ×1

wagtail ×1