I am currently using
forms.Form type for one of my forms because I needed to specify many parameters for them, such as queryset, disabled, required.
Snippet of the parameters I am talking about in my
class InputClassInformation(forms.Form): module = forms.ModelChoiceField(queryset=Module.objects.all()) title = forms.CharField(disabled=True, required=False)
The form will allow users to update certain fields in an entry, that means I will have to use the
instance parameter as seen in here https://docs.djangoproject.com/en/2.2/topics/forms/modelforms/#the-save-method . However, I get this error when I run my code in
if Class.objects.filter(module__subject=subject).exists(): a = Class.objects.filter(module__subject=subject).pk form = InputClassInformation(request.POST, instance=a)
TypeError at /input-class-info/ __init__() got an unexpected keyword argument 'instance'
I know this would have been fine if I was using
ModelForm, but trying to specify all the parameters I need in
ModelForm has been difficult, so is there a way I can specify the instance I want to update while using