def url_path_fix(apps, schema_editor):
# cannot use apps.get_model here
# because Page instances wouldn't have set_url_path method
from wagtail.wagtailcore.models import Page
url_path_fields = get_translation_fields('url_path')
for page in Page.objects.order_by('path').iterator():
page.set_url_path(page.get_parent())
# make sure descendant page url paths are not updated at this point
# because it would fail
page.save(update_fields=url_path_fields)
评论列表
文章目录