forms.py 文件源码

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

项目:9XD 作者: 9XD 项目源码 文件源码
def save(self, commit=True):
        author = self.cleaned_data['author']
        title = self.cleaned_data['title']
        content = self.cleaned_data['content']
        markdown = Markdown()
        html = markdown.convert(content)
        post = Post(author=author, title=title, content=content, html=html)
        post.save()

        tags_text = self.cleaned_data['tags']
        tag_names = split_tags(tags_text)
        for tag_name in tag_names:
            tag_name.strip()
            if 0 < len(tag_name) < 16:
                tag = self.create_and_get(tag_name)
                post.tags.add(tag)

        return self.instance
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号