forms.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:django-danceschool 作者: django-danceschool 项目源码 文件源码
def __init__(self,*args,**kwargs):
        self._request = kwargs.pop('request',None)
        user = getattr(self._request,'user',None)
        payAtDoor = kwargs.pop('payAtDoor',False)

        super(PrivateLessonStudentInfoForm,self).__init__(*args,**kwargs)

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_tag = False  # Our template must explicitly include the <form tag>

        if user and hasattr(user,'customer') and user.customer and not payAtDoor:
            # Input existing info for users who are logged in and have signed up before
            self.fields['firstName'].initial = user.customer.first_name or user.first_name
            self.fields['lastName'].initial = user.customer.last_name or user.last_name
            self.fields['email'].initial = user.customer.email or user.email
            self.fields['phone'].initial = user.customer.phone

        self.helper.layout = Layout(
            Div('firstName','lastName','email',css_class='form-inline'),
            Div('phone',css_class='form-inline'),
            Div('agreeToPolicies',css_class='card card-body bg-light'),
            Submit('submit',_('Complete Registration'))
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号