X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/05ce0b5f9bd62d1b369a6718bec1b70e0a4a0fef..cad3fe955a1d238e7157d63205b2ed6440f5b422:/forum/views.py diff --git a/forum/views.py b/forum/views.py index 7eb412e..41b7eb8 100644 --- a/forum/views.py +++ b/forum/views.py @@ -1,6 +1,9 @@ +from django.core.exceptions import ObjectDoesNotExist import pybb.views import pybb.forms +from catalogue.models import Lesson + from .forms import PostForm from .models import Topic @@ -48,5 +51,9 @@ class EditPostView(PostEditMixin, pybb.views.EditPostView): def get_form_kwargs(self): kwargs = super(EditPostView, self).get_form_kwargs() - kwargs['initial']['lesson'] = self.object.topic.edumed_topic.lesson + try: + lesson = self.object.topic.edumed_topic.lesson + except ObjectDoesNotExist: + lesson = None + kwargs['initial']['lesson'] = lesson return kwargs