This commit is contained in:
Ross
2021-11-28 17:05:15 +00:00
parent a03c452d7c
commit fd72594be8
2 changed files with 14 additions and 1 deletions
+13
View File
@@ -38,6 +38,19 @@ class SeriesFindingsForm(ModelForm):
model = SeriesFindings
exclude = [""]
def __init__(self, *args, **kwargs):
if kwargs.get("series_id"):
# 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["series"] = kwargs["series_id"].id
super(SeriesFindingsForm, self).__init__(*args, **kwargs)
ModelForm.__init__(self, *args, **kwargs)
class SeriesForm(ModelForm):
class Media:
# Django also includes a few javascript files necessary
+1 -1
View File
@@ -117,7 +117,7 @@ def series_detail(request, pk):
# if request.user not in atlas.author.all():
# raise PermissionDenied
series_finding_form = SeriesFindingsForm()
series_finding_form = SeriesFindingsForm(series_id=series.id)
# logging.debug(atlas.subspecialty.first().name.all())