website/conservancy/supporters/forms.py

29 lines
863 B
Python

from django import forms
from .models import SustainerOrder
class SustainerForm(forms.ModelForm):
amount_monthly = forms.IntegerField(initial=12, required=False)
class Meta:
model = SustainerOrder
fields = [
'name',
'email',
'amount',
'acknowledge_publicly',
'add_to_mailing_list',
'tshirt_size',
'street',
'city',
'state',
'zip_code',
'country',
]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['amount'].widget.attrs['style'] = 'width: 5rem'
self.fields['amount'].initial = 128
self.fields['amount_monthly'].widget.attrs['style'] = 'width: 5rem'
self.fields['tshirt_size'].widget.attrs['x-model'] = 'tshirt_size'