0
如何添加:Django的:如何提交表單whes用戶點擊單選按鈕
onclick="this.form.submit();"
在我的單選按鈕形式?我想在用戶點擊單選按鈕時發佈我的表單。
class MyForm(forms.Form):
def __init__(self, *args, **kwargs):
self.news = kwargs.pop('news')
super(MyForm, self).__init__(*args, **kwargs)
choices = ([ ("%s" % a.id, "%s" % a.text) for a in self.news])
self.fields['new'] = forms.ChoiceField(choices = choices, widget=forms.RadioSelect())
我想有這樣的結果模板: