Django,如何将多个表单与一个字段默认为表单名称

时间:2017-12-06 11:08:41

标签: django-forms

我在网格系统中有一个公司徽标列表,每个徽标都链接到同一个弹出窗体。我喜欢名称,电子邮件,电话,地区等字段。我希望每个表单都有一个与公司徽标名称相同的默认字段,我该怎么做????这是我的代码。

FORMS.PY

MARKETING_CHOICES = (('Yes', 'Yes'), ('No', 'No'))

class TechnologyForm(forms.Form):
    name = forms.CharField(max_length=50)
    email = forms.EmailField()
    number = forms.IntegerField()
    region = forms.CharField()
    email_marketing = forms.ChoiceField(choices=MARKETING_CHOICES)


class BoxuserForm(TechnologyForm):
    required_service_for = forms.CharField(max_length)

VIEWS.PY

class Technology_listView(TemplateView):
    template_name = 'upload/technology_list.html'
    def post(self, request):
        form = AwsuserForm(request.POST)

        if form.is_valid():
            name = form.cleaned_data.get('name')
            email = form.cleaned_data.get('email')
            phone = form.cleaned_data.get('phone')
            region = form.cleaned_data.get('region')
            required_service_for = form.cleaned_data.get('required_service_for')
            email_marketing = form.cleaned_data.get('email_marketing')
            save.form()

0 个答案:

没有答案