From 0202d5ba93074de0c62736e03baf3300ddb1ff5d Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Thu, 28 Sep 2017 22:56:33 +0200 Subject: [PATCH] Add initial values for dcl billing form --- datacenterlight/views.py | 3 ++- utils/forms.py | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index a6732d83..c45aea61 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -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 diff --git a/utils/forms.py b/utils/forms.py index a856eb8d..f8a6d103 100644 --- a/utils/forms.py +++ b/utils/forms.py @@ -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(),