Django: Get the form name or id from template

前端 未结 3 1720
星月不相逢
星月不相逢 2021-01-24 12:21

If you have multiple forms

from django import forms

class NameForm(forms.Form):
    your_name = forms.CharField(label=\'Your name\', max_length=100)

class Sec         


        
3条回答
  •  醉梦人生
    2021-01-24 12:58

    If you use a unique prefix for each form, then the fields will all have unique ids.

    form1 = NameForm(prefix='name') 
    form2 = SecondNameForm(prefix='second_name') 
    

提交回复
热议问题