This commit is contained in:
Ross
2021-11-24 22:32:54 +00:00
parent 4b6d31e474
commit c5fdc39715
2 changed files with 17 additions and 0 deletions
+11
View File
@@ -81,6 +81,17 @@ class LongSeriesForm(ModelForm):
js = ["jsi18n.js", "tesseract.min.js"]
def __init__(self, *args, **kwargs):
self.user = kwargs.pop(
"user"
) # To get request.user. Do not use kwargs.pop('user', None) due to potential security hole
if kwargs.get("instance"):
# We get the 'initial' keyword argument or initialize it
# as a dict if it didn't exist.
initial = kwargs.setdefault("initial", {})
# The widget for a ModelMultipleChoiceField expects
# a list of primary key for the selected data.
initial["long"] = [t.pk for t in kwargs["instance"].exams.all()]
super(LongSeriesForm, self).__init__(*args, **kwargs)
# self.fields["examination"] = ModelChoiceField(
# queryset=Examination.objects.all(),