class ClearForm(forms.Form):
CITY = forms.ModelChoiceField(queryset=Numbers.objects.values('CITY__city'))
GROUP = forms.ModelChoiceField(queryset=Numbers.objects.values('GROUP__group'))
FIO = forms.ModelChoiceField(queryset=Numbers.objects.values('FIO'))
DATE_CLEAR = forms.DateInput()
HOUR_FROM = forms.Select()
HOUR_TO = forms.Select()
COMMENT = forms.TextInput()
def clean(self):
hour_from = self.cleaned_data['HOUR_FROM']
hour_to = self.cleaned_data['HOUR_TO']
if hour_from > hour_to:
raise ValidationError('"Время C" должно быть меньше')
return self.cleaned_data
Internal Server Error: /add_line2clear/
Traceback (most recent call last):
File "C:\Users\PPKorchagin\Documents\development\multi\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\PPKorchagin\Documents\development\multi\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\PPKorchagin\Documents\development\multi\lib\site-packages\django\views\generic\base.py", line 73, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\PPKorchagin\Documents\development\multi\lib\site-packages\django\contrib\auth\mixins.py", line 85, in dispatch
return super().dispatch(request, *args, **kwargs)
File "C:\Users\PPKorchagin\Documents\development\multi\lib\site-packages\django\views\generic\base.py", line 101, in dispatch
return handler(request, *args, **kwargs)
File "C:\Users\PPKorchagin\Documents\development\multi\lib\site-packages\django\views\generic\edit.py", line 168, in get
return super().get(request, *args, **kwargs)
File "C:\Users\PPKorchagin\Documents\development\multi\lib\site-packages\django\views\generic\edit.py", line 133, in get
return self.render_to_response(self.get_context_data())
File "C:\Users\PPKorchagin\Documents\development\multi\lib\site-packages\django\views\generic\edit.py", line 66, in get_context_data
kwargs['form'] = self.get_form()
File "C:\Users\PPKorchagin\Documents\development\multi\lib\site-packages\django\views\generic\edit.py", line 33, in get_form
return form_class(**self.get_form_kwargs())
TypeError: __init__() got an unexpected keyword argument 'instance'
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for field in self.fields:
self.fields[field].widget.attrs['class'] = 'form-control'