I see this problem a lot here on SO, and the cause is usually the same. You have overridden the init method and changed the signature, so that the first element is now customer
, not data
. But when you instantiate it in your view, you pass request.POST
first, so the parameters don't match up to the right variables.
In addition, you don't pass the parameters into the super method, so the POST is never even seen.
Do this instead:
class GroupForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
self.customer = kwargs.pop('customer', None)
super(GroupForm, self).__init__(*args, **kwargs)
and in the view:
form = GroupForm(request.POST, customer=customer, instance=group)