python - Django - Custom save() got an unexpected keyword argument 'instance' -
so have model form, custom save()
method. when pass variable instance
form, following error:
save() got unexpected keyword argument 'instance'
how handle instance
argument in save method? know commit
it's simple boolean handle, seems more complicated when passing object. bunch!
class updateorderform(forms.modelform): #some data here class meta: model = order def save(self, instance): updatedorder= super(updatedorderform, self).save() #some stuff happens here return updatedorder
in django documentation stated save() takes commit argument.
def save(self, commit=true): updatedorder = super(updatedorderform, self).save(commit=false) # other things related form if commit: updatedorder.save() return updatedorder
earlier saved in updatedorder did not committed operations related form , once done commit database.
Comments
Post a Comment