Reputation: 13
I'm trying to display an HTMLCalendar in my django project but it's only displaying the html code instead of the actual Calendar.
views.py
def CalendarView(request):
cal = HTMLCalendar().formatmonth(2020, 10, withyear=True).replace('<td ', '<td width="150" height="150"')
return render(request, 'calendar.html', {'cal': cal})
calendar.html
{% extends 'base.html' %}
{% block tilte %} Home {% endblock %}
{% block body %}
<div id="content-main">
<ul class="object-tools">
<li>
<a href={{ previous_month }}>
Previous month
</a>
</li>
<li>
<a href={{ next_month }}>
Next month
</a>
</li>
</ul>
{{ cal }}
{% endblock %}
This is what gets displayed instead of the actual calendar
Upvotes: 1
Views: 395
Reputation: 36
This is what you would want to put instead of just {{ cal }}
.
{{ cal|safe }}
Upvotes: 2