[Python] How to make tags translatable in Wagtail using the Localize module?

Discussão em 'Python' iniciado por Stack, Janeiro 26, 2025.

  1. Stack

    Stack Membro Participativo

    In my multilingual site, when I display the page of an article, the tags remain in English while in the admin, the tag has been translated into French.

    So how do I proceed so that the translated page is displayed with the translated tags?

    class Insight(Page):
    ...
    tags = ClusterTaggableManager(through='insight.InsightTag', blank = True)

    ...


    @register_snippet
    class InsightTag(
    TranslatableMixin,
    TaggedItemBase
    ):

    content_object = ParentalKey(
    to='insight.Insight',
    related_name='tagged_items',
    on_delete=models.CASCADE
    )

    def get_preview_template(self, request, mode_name):
    return "base.html"

    def get_preview_context(self, request, mode_name):
    return {"insighttag": self.body}

    class Meta(TranslatableMixin.Meta):
    verbose_name = "insight Tag"
    verbose_name_plural = "insight Tags"

    Continue reading...

Compartilhe esta Página