def create_slug(sender, instance, *args, **kwargs):
if not instance.slug:
if hasattr(sender, "name"):
instance.slug = slugify(instance.name)
if hasattr(sender, "title"):
instance.slug = slugify(instance.title)
else:
raise AttributeError("No name or title found!")
return instance
评论列表
文章目录