[Fixed]-How to set current user to be an attribute of the ModelForm?

1👍

Your are not calling the .save method correctly. super accepts a second argument which is the object instance.

super(ReservationCreationForm, self).save(*args, **kwargs)

UPDATE

You are not setting customer to a reservation instance, but to a form instance, that’s why your reservation object does not have a customer.

try with this one, (and don’t forget the return):

def save(self, user, *args,**kwargs):
    self.instance.customer = user 
    return super(ReservationCreationForm, self).save(*args, **kwargs)
👤Todor

Leave a comment