django onchange提交整个表格

时间:2017-02-07 03:49:59

标签: django forms

我知道之前已经解决了这个问题,但我无法进行更改提交工作。这是我的forms.py在模型或视图中没什么特别之处。我放心,我只选择了一个字段,但是如果它有用,我会把它应用到其他字段?

#forms.py
from django import forms
from .models import rapidTill

class RapidTillForm(forms.ModelForm):
    class Meta:
        widgets = {'linkArms': forms.RadioSelect(attrs={'onchange': 'RapidTillForm.submit();'}), 'shank':forms.RadioSelect,
        'caddy':forms.RadioSelect, 'liftAssist': forms.RadioSelect, 'folding': forms.RadioSelect}
        fields = ['rows', 'space', 'folding', 'shank', 'caddy', 'linkArms', 'liftAssist','shank',]
        model = rapidTill

和我的form-template.html

{% for field in form %}
    <span>{{field.errors}}</span>
    <label>{{field.label_tag}}</label>
    {{field}}</br>
{%endfor%}

1 个答案:

答案 0 :(得分:0)

&#39; submint&#39;不需要前面的型号名称

class RapidTillForm(forms.ModelForm):
    class Meta:
        widgets = {'linkArms': forms.RadioSelect(attrs={'onchange': 'submit();'}), 'shank':forms.RadioSelect,
        'caddy':forms.RadioSelect, 'liftAssist': forms.RadioSelect, 'folding': forms.RadioSelect}
        fields = ['rows', 'space', 'folding', 'shank', 'caddy', 'linkArms', 'liftAssist','shank',]
        model = rapidTill