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)
评论列表
文章目录