Answers for "markdown and markdownv2"

1

python package markdown2 how to use

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
Posted by: Guest on July-12-2020

Python Answers by Framework

Browse Popular Code Answers by Language