def __init__(self, *args, **kwargs):
super(CreateCommandForm, self).__init__(*args, **kwargs)
# if you want to do it to all of them
for field in self.fields.values():
field.error_messages = {'required':'Это поле обязательно для заполнения'}
class UpdateView(FormView):
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs['user'] = self.request.user
return kwargs
class UpdateForm(forms.Form):
def __init__(self, *args, **kwargs):
user = kwargs.pop('user')
super().__init__(*args, **kwargs)
if not user.groups.filter(name='managers').exists():
self.fields['secret'].disabled = True