{% load i18n %}
-<h5 style="margin-top: -20px;">{% trans 'Related lesson' %}: <a href="{{lesson.get_absolute_url}}">{{lesson.title}}</a></h4>
\ No newline at end of file
+{% if lesson %}
+<h5 style="margin-top: -20px;">{% trans 'Related lesson' %}: <a href="{{lesson.get_absolute_url}}">{{lesson.title}}</a></h5>
+{% endif %}
\ No newline at end of file