X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/05ce0b5f9bd62d1b369a6718bec1b70e0a4a0fef..63afb46b7a39881c3a3655af645d5414bdd730ea:/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