我很抱歉这很愚蠢。但我无法理解此错误消息:
这是我的表格。py:
class group1Form(forms.ModelForm):
class Meta:
model = group1
fields = ('group_Name', 'Master', 'Nature_of_group1', 'balance_nature', 'Group_behaves_like_a_Sub_Ledger', 'Nett_Debit_or_Credit_Balances_for_Reporting')
widgets = {
'group_Name': forms.TextInput(attrs= {'class' : 'form-control'}),
}
def __init__(self, *args, **kwargs):
super(group1Form, self).__init__(*args, **kwargs)
self.fields['Master'].widget.attrs = {'class': 'form-control select2',}
self.fields['Nature_of_group1'].widget.attrs = {'class': 'form-control select2',}
self.fields['balance_nature'].widget.attrs = {'class': 'form-control select2',}
这是我的views.py:
class group1CreateView(LoginRequiredMixin,CreateView):
form_class = group1Form
template_name = "accounting_double_entry/group1_form.html"
def form_valid(self, form):
form.instance.User = self.request.user
form.instance.Company = self.kwargs['pk']
return super(group1CreateView, self).form_valid(form)
错误回传:
Traceback:
File "C:\Users\HP\myEnv\lib\site-packages\django\core\handlers\exception.py" in inner
35. response = get_response(request)
File "C:\Users\HP\myEnv\lib\site-packages\django\core\handlers\base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "C:\Users\HP\myEnv\lib\site-packages\django\core\handlers\base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
Exception Type: TypeError at /accounting_double_entry/groupcreate/
Exception Value: __init__() takes 1 positional argument but 2 were given
谁能告诉我这段代码我到底在做什么错??? 只是想不通
谢谢