.
This commit is contained in:
+4
-2
@@ -33,6 +33,7 @@ class QuestionNoteForm(ModelForm):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
question_type = kwargs.pop("question_type")
|
question_type = kwargs.pop("question_type")
|
||||||
|
pk = kwargs.pop("pk")
|
||||||
|
|
||||||
if question_type == "rapid":
|
if question_type == "rapid":
|
||||||
question = Rapid
|
question = Rapid
|
||||||
@@ -43,13 +44,14 @@ class QuestionNoteForm(ModelForm):
|
|||||||
else:
|
else:
|
||||||
raise PermissionError()
|
raise PermissionError()
|
||||||
|
|
||||||
get_object_or_404(question, pk=kwargs.pop("pk"))
|
get_object_or_404(question, pk=pk)
|
||||||
# We get the 'initial' keyword argument or initialize it
|
# We get the 'initial' keyword argument or initialize it
|
||||||
# as a dict if it didn't exist.
|
# as a dict if it didn't exist.
|
||||||
initial = kwargs.setdefault("initial", {})
|
initial = kwargs.setdefault("initial", {})
|
||||||
# The widget for a ModelMultipleChoiceField expects
|
# The widget for a ModelMultipleChoiceField expects
|
||||||
# a list of primary key for the selected data.
|
# a list of primary key for the selected data.
|
||||||
#initial["content_type"] = [t.pk for t in kwargs["instance"].exams.all()]
|
initial["content_type"] = question
|
||||||
|
initial["content_id"] = pk
|
||||||
|
|
||||||
ModelForm.__init__(self, *args, **kwargs)
|
ModelForm.__init__(self, *args, **kwargs)
|
||||||
#super(QuestionNoteForm(), self).__init__(*args, **kwargs)
|
#super(QuestionNoteForm(), self).__init__(*args, **kwargs)
|
||||||
Reference in New Issue
Block a user