def get_context_data(self, **kwargs):
context = super(StaticPageViewBase, self).get_context_data(**kwargs)
if not self.slug:
self.slug = kwargs['slug']
filename = self.get_markdown_filename()
try:
input_file = codecs.open(
filename,
mode="r",
encoding="utf-8"
)
except FileNotFoundError:
raise Http404
text = input_file.read()
html = markdown.markdown(text)
context['html_content'] = html
return context
评论列表
文章目录