infoportugal/wagtail-modeltranslation

Support for wagtaildocs Document reference

Closed this issue · 1 comments

Addind translation support doesn't seem to work for wagtaildocs.Document foreign keys.

Considering the following code:

from django.db import models
from modeltranslation.decorators import register
from modeltranslation.translator import TranslationOptions
from wagtail.core.models import Page
from wagtail.documents.edit_handlers import DocumentChooserPanel
from wagtail.images.edit_handlers import ImageChooserPanel

class MyPage(Page):
    image = models.ForeignKey(
        "wagtailimages.Image",
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )

    document = models.ForeignKey(
        "wagtaildocs.Document", 
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name="+",
    )

    content_panels = Page.content_panels + [
        ImageChooserPanel("image"),
        DocumentChooserPanel("document"),
    ]

@register(MyPage)
class MyPageTR(TranslationOptions):
    fields = (
        "image",
        "document",
    )

The editor interface correctly shows translation versions for the image field but not for document.
Did I miss anything?

Running on:

  • wagtail==2.10.2
  • wagtail-modeltranslation==0.10.15

I just ran into this myself. After a little digging into the code, I found this setting which seems to solve the problem:

WAGTAILMODELTRANSLATION_CUSTOM_SIMPLE_PANELS = ['wagtail.documents.edit_handlers.DocumentChooserPanel']