コード例 #1
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     if self.request.POST:
         context["options"] = CategoricalOptionFormSet(self.request.POST)
     else:
         context["options"] = CategoricalOptionFormSet()
     context.update({"reader_study": self.reader_study})
     return context
コード例 #2
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     form_fields = context["form"].fields
     for field_name in self.object.read_only_fields:
         form_fields[field_name].required = False
         form_fields[field_name].disabled = True
     if self.request.POST:
         context["options"] = CategoricalOptionFormSet(self.request.POST,
                                                       instance=self.object)
     else:
         context["options"] = CategoricalOptionFormSet(instance=self.object)
     context.update({"reader_study": self.reader_study})
     return context