From 4f8aaefea2457a503d1098c2c0378b270199c2b9 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 27 Dec 2020 19:16:34 +0000 Subject: [PATCH] . --- anatomy/forms.py | 2 -- anatomy/views.py | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/anatomy/forms.py b/anatomy/forms.py index f3210166..01886f65 100644 --- a/anatomy/forms.py +++ b/anatomy/forms.py @@ -95,8 +95,6 @@ class AnatomyQuestionForm(ModelForm): #) - # Only in case we build the form from an instance - # (otherwise, 'toppings' list should be empty) if kwargs.get('instance'): # We get the 'initial' keyword argument or initialize it # as a dict if it didn't exist. diff --git a/anatomy/views.py b/anatomy/views.py index 91c54839..91783eb7 100644 --- a/anatomy/views.py +++ b/anatomy/views.py @@ -979,6 +979,10 @@ class QuestionClone(AnatomyQuestionCreateBase): old_object = get_object_or_404(AnatomyQuestion, pk=self.kwargs["pk"]) initial_data = model_to_dict(old_object, exclude=["id"]) + exams = old_object.exams.all().values_list("id", flat=True) + + initial_data["exams"] = list(exams) + return initial_data