我想从小部件attr形式传递上下文。例子
self.fields ['accesses']。widget.attrs ['value'] ='{{company.id}},{{functionality.id}}'
class ACLFormAdd(forms.Form):
accesses = forms.BooleanField(required=False)
def __init__(self, *args, **kwargs):
super(ACLFormAdd, self).__init__(*args, **kwargs)
self.fields['accesses'].widget.attrs['name'] = 'accesses'
self.fields['accesses'].widget.attrs['value'] = '{{company.id}},{{functionality.id}}'