Open
Description
Wagtail page model has exclude_fields_in_copy
, but when personalisation create varient page, it does'n use this. We use hit count
as GenericRelation model, This through type error.
Our team use this way for temp:
def copy_for_segment(self, segment, exclude_fields=None):
exclude_fields_in_copy = ["hit_count_generic"]
default_exclude_fields_in_copy = ['id', 'path', 'depth', 'numchild', 'url_path', 'path', 'index_entries', 'comments']
exclude_fields = default_exclude_fields_in_copy + exclude_fields_in_copy +(exclude_fields or [])
page = self.canonical_page
slug = "{}-{}".format(page.slug, segment.encoded_name())
title = "{} ({})".format(page.title, segment.name)
update_attrs = {
'title': title,
'slug': slug,
'live': False,
}
with transaction.atomic():
new_page = self.canonical_page.copy(
update_attrs=update_attrs, copy_revisions=False, exclude_fields=exclude_fields)
PersonalisablePageMetadata.objects.create(
canonical_page=page,
variant=new_page,
segment=segment)
return new_page
Same as page copy methord.
Will sent a PR later.
Metadata
Metadata
Assignees
Labels
No labels