def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
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
def get_context_data(self, **kwargs): context = super(CourseDetailView, self).get_context_data(**kwargs) context["enroll_form"] = CourseEnrollForm( initial={"course": self.object}) return context
def get_context_data(self, **kwargs): context = super(CourseDetailView, self).get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( # 增加一个表单上下文 initial = {'course': self.object} ) return context
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