Add initial values for dcl billing form

This commit is contained in:
M.Ravi 2017-09-28 22:56:33 +02:00
parent fcda0b5637
commit 0202d5ba93
2 changed files with 2 additions and 12 deletions

View file

@ -349,8 +349,9 @@ class PaymentOrderView(FormView):
'instance': self.request.user.billing_addresses.first()
})
if 'billing_address_data' in self.request.session:
billing_address_data = self.request.session['billing_address_data']
form_kwargs.update({
'billing_address_data': self.request.session['billing_address_data']
'initial': billing_address_data
})
return form_kwargs

View file

@ -118,12 +118,6 @@ class EditCreditCardForm(forms.Form):
class BillingAddressForm(forms.ModelForm):
token = forms.CharField(widget=forms.HiddenInput(), required=False)
def __init__(self, *args, **kwargs):
billing_address_data = kwargs.get('billing_address_data', {})
kwargs['initial'] = billing_address_data
super(BillingAddressForm, self).__init__(*args, **kwargs)
class Meta:
model = BillingAddress
fields = ['cardholder_name', 'street_address',
@ -142,11 +136,6 @@ class BillingAddressFormSignup(BillingAddressForm):
email = forms.EmailField(label=_('Email Address'))
field_order = ['name', 'email']
def __init__(self, *args, **kwargs):
billing_address_data = kwargs.get('billing_address_data', {})
kwargs['initial'] = billing_address_data
super(BillingAddressFormSignup, self).__init__(*args, **kwargs)
class UserBillingAddressForm(forms.ModelForm):
user = forms.ModelChoiceField(queryset=CustomUser.objects.all(),