我的观点如下:
class ListAndCreate(CreateView):
model = xmpp_buddy_groups
form_class = xmpp_buddy_groups_form
second_form_class = sip_extension_form
template_name = "xmpp/index.html"
success_url = reverse_lazy('xmpp:index')
我的表格如下:
class xmpp_buddy_groups_form(forms.ModelForm):
class Meta:
model = xmpp_buddy_groups
fields = ['group_name']
class sip_extension_form(forms.ModelForm):
class Meta:
model = SipExtension
fields = ['sip_extension']
widgets = {
"sip_extension": forms.Select
}
当我在模板中使用表单{{form.as_p}}时,我想在模板中填充sip_extension的数据。但我不知道我该怎么做。