1
You’ve made parent_id
the first positional argument to the form, so you should pass it as such in the POST block:
form = AddressForm(parent_id, request.POST)
Note that it is better not to change the signature of the form at all, but use kwargs:
def __init__(self, *args, **kwargs):
parent_id = kwargs.pop('parent_id', None)
super(AddressForm, self).__init__(*args, **kwargs)
and do:
form = AddressForm(request.POST, parent_id=parent_id)
in the POST block and
form = AddressForm(parent_id=parent_id)
in the else.
Source:stackexchange.com