コード例 #1
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     context['enroll_form'] = CourseEnrollForm(
         initial={'course': self.object})
     return context
コード例 #2
0
ファイル: views.py プロジェクト: okidijimmy200/educa
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     context['enroll_form'] = CourseEnrollForm(
         # initialize the hidden course field of the form with the current Course object so that it can be submitted directly.
         initial={'course': self.object})
     return context
コード例 #3
0
ファイル: views.py プロジェクト: Lilenn/cons
 def get_context_data(self, **kwargs):
     context = super(CourseDetailView, self).get_context_data(**kwargs)
     context["enroll_form"] = CourseEnrollForm(
         initial={"course": self.object})
     return context
コード例 #4
0
 def get_context_data(self, **kwargs):
     context = super(CourseDetailView, self).get_context_data(**kwargs)
     context['enroll_form'] = CourseEnrollForm(  # 增加一个表单上下文
         initial = {'course': self.object}
     )
     return context
コード例 #5
0
 def get_context_data(self, **kwargs):
     context = super(CourseDetailView, self).get_context_data(**kwargs)
     # 初始化带有当前Course对象的表单的隐藏course字段
     context['enroll_form'] = CourseEnrollForm(initial={'course': self.object})
     return context