60π
β
I usually just do essentially what youβre doing here. However, you can shorten/clean up your code by supplying a default argument to dict.pop
:
def __init__(self, *args, **kwargs):
user = kwargs.pop('user', None)
super(BaseCheckoutForm, self).__init__(*args, **kwargs)
if user is not None:
self.prefill_from_user(user)
π€Joe Kington
Source:stackexchange.com