page_patch.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:wagtail-translation 作者: skirsdeda 项目源码 文件源码
def full_clean(self, *args, **kwargs):
    # autogenerate slugs for non-empty title translation
    for lang_code in mt_settings.AVAILABLE_LANGUAGES:
        title_field = build_localized_fieldname('title', lang_code)
        slug_field = build_localized_fieldname('slug', lang_code)

        title = getattr(self, title_field)
        slug = getattr(self, slug_field)
        if title and not slug:
            if DJANGO_VERSION >= (1, 9):
                base_slug = slugify(title, allow_unicode=True)
            else:
                base_slug = slugify(title)

            if base_slug:
                setattr(self, slug_field, self._get_autogenerated_lang_slug(base_slug, lang_code))

    super(Page, self).full_clean(*args, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号