複数のデータベースを使用しています
DATABASES = {
'default': {
# for local postgre databases
'ENGINE': 'django.db.backends.postgresql',
'NAME': '2003',
'USER' : 'postgres',
'PASSWORD' : '3211',
'HOST' : 'localhost',
},
'[email protected]': {
# for local postgre databases
'ENGINE': 'django.db.backends.postgresql',
'NAME': '[email protected]',
'USER' : 'postgres',
'PASSWORD' : '3211',
'HOST' : 'localhost',
}
}
今、inlineformset_factory を使用中に保存しようとしています([email protected])
しかしエラーが発生します
「save() が予期しないキーワード引数を「使用」して取得しました。
views.py で使用している場所
def panelList (request, id=None):
detail = Panel.objects.using(username).filter(user=request.user).order_by('detail')
buttonlable = "Panel List"
heading = "Panel List"
formset = modelformset_factory(Panel, extra=1, max_num=1, can_delete=False,
fields=('user','detail','panel_type','billing_address','contact','contact_person','status','email',),
labels={'user':'','detail':'','panel_type':'','billing_address':'','contact':'','contact_person':'','status':'','email':'',},
widgets={
'user' : forms.HiddenInput(attrs={'placeholder':'user','class':'form-control col-sm mr-1 mt-1 border-muted bg-light border border-info','required':'true', 'value':user,}),
'detail' : forms.TextInput(attrs={'placeholder':'Name','class':'form-control col-sm mr-1 mt-1 border-muted bg-light border border-info','required':'true'}),
'panel_type' : forms.TextInput(attrs={'placeholder':'Type','class':'form-control col-sm mr-1 mt-1 border-muted bg-light border border-info','required':'true'}),
'billing_address' : forms.TextInput(attrs={'placeholder':'Address','class':'form-control col-sm mr-1 mt-1 border-muted bg-light border border-info','required':'true'}),
'contact' : forms.TextInput(attrs={'placeholder':'Contact','class':'form-control col-sm mr-1 mt-1 border-muted bg-light border border-info','required':'true'}),
'contact_person' : forms.TextInput(attrs={'placeholder':'Contact Person','class':'form-control col-sm mr-1 mt-1 border-muted bg-light border border-info','required':'true'}),
'email' : forms.TextInput(attrs={'placeholder':'email','class':'form-control col-sm mr-1 mt-1 border-muted bg-light border border-info','required':'true'}),
'status': forms.HiddenInput(attrs={'placeholder':'status', 'class':'form-control col-sm mr-1 mt-1 bg-light border-muted'})})
if request.method == "POST":
formset = formset(request.POST)
for form in formset:
if form.is_valid:
form.save(commit=False)
form.user = request.user
form.save([email protected])
return redirect("panelList")
------------------------
データベース名を引用符で囲む必要があります。 form.save(using='[email protected]')
0