If a snippet model definition contains two nested levels of InlinePanel children, then copying an item for translation results in the grandchild objects being moved from the source record to the translated record, instead of being copied.
Starting with a fresh Wagtail 6.2a0 instance with wagtail-localize installed and configured as
from django.db import models
from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from wagtail.admin.panels import FieldPanel, InlinePanel
from wagtail.models import Page, TranslatableMixin
from wagtail.snippets.models import register_snippet
class HomePage(Page):
pass
@register_snippet
class Event(TranslatableMixin, ClusterableModel):
name = models.CharField(max_length=255)
def __str__(self):
return self.name
panels = [
FieldPanel('name'),
InlinePanel('sessions', label="Sessions"),
]
class Session(TranslatableMixin, ClusterableModel):
event = ParentalKey(Event, related_name='sessions')
name = models.CharField(max_length=255)
def __str__(self):
return self.name
panels = [
FieldPanel('name'),
InlinePanel('speakers', label="Speakers"),
]
class Speaker(TranslatableMixin, models.Model):
session = ParentalKey(Session, related_name='speakers')
name = models.CharField(max_length=255)
def __str__(self):
return self.name
panels = [
FieldPanel('name'),
]
Add French as a locale
Create an Event snippet with name = Christmas, session name = Christmas Day, speaker name = Santa Claus
Check the database and note the ID of the created record in home_speaker
From the snippet listing, select Translate -> French, enter translations ("Noël", "le jour de Noël", "Père Noël"), then "Publish in French"
The original English event is now missing the record for Santa Claus
Checking the database again shows that the original record in home_speaker has been updated with the translation and attached to the new Session record, instead of being copied.
If a snippet model definition contains two nested levels of InlinePanel children, then copying an item for translation results in the grandchild objects being moved from the source record to the translated record, instead of being copied.
Starting with a fresh Wagtail 6.2a0 instance with wagtail-localize installed and configured as
and home/models.py as follows:
home_speaker
home_speaker
has been updated with the translation and attached to the new Session record, instead of being copied.