I'm trying to use markdown to avoid typing HTML in my wiki form, but for some reason the form displays HTML code instead of the intended formatting.
My view function is as follows:
from django.shortcuts import render_to_response
from mywiki.wiki.models import Page
from django.http import HttpResponseRedirect
import markdown
def view_page(request, page_name):
try:
page = Page.objects.get(pk=page_name)
except Page.DoesNotExist:
return render_to_response('create.html', {'page_name':page_name})
content = page.content
return render_to_response('view.html', {'page_name':page_name, 'content':markdown.markdown(content)})
This is my view.html template:
{% extends 'base.html' %}
{% load wikilink %}
{% block title %}{{page_name}}{% endblock %}
{% block content %}
<h1>{{page_name}}</h1>
{{content|wikify}}
<hr/>
<a href='/mywiki/{{page_name}}/edit/'>Edit this page?</a>
{% endblock %}
And this is my base.html:
<html>
<head>
<title>{{% block title %}{% endblock %}</title>
</head>
<body>
<div>
Menu: <a href='/mywiki/Start/'>Start Page</a>
</div>
{% block content %}
{% endblock %}
</body>
</html>
I have an established markdown and the version of Django is 1.4.1 (Mac).
Thank.
source
share