Skip to content

Commit

Permalink
Show rendered markdown in entries list
Browse files Browse the repository at this point in the history
  • Loading branch information
salmanulfarzy committed Mar 10, 2017
1 parent 1df4f6c commit 56bc880
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
Binary file modified db.sqlite3
Binary file not shown.
2 changes: 1 addition & 1 deletion learning_logs/templates/learning_logs/topic.html
Expand Up @@ -24,7 +24,7 @@ <h3>
</h3>
</div>
<div class="panel-body">
{{ entry.text | linebreaks }}
{{ entry.markdown_field|safe }}
</div>
</div>
{% empty %}
Expand Down
4 changes: 4 additions & 0 deletions learning_logs/views.py
Expand Up @@ -3,6 +3,8 @@
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import render, get_object_or_404

from markdownx.utils import markdownify

from .forms import TopicForm, EntryForm
from .models import Topic, Entry

Expand All @@ -28,6 +30,8 @@ def topic(request, topic_id):
if topic.owner != request.user:
raise Http404
entries = topic.entry_set.order_by('-date_added')
for entry in entries:
entry.markdown_field = markdownify(entry.markdown_field)
context = {'topic': topic, 'entries': entries}
return render(request, 'learning_logs/topic.html', context)

Expand Down

0 comments on commit 56bc880

Please sign in to comment.