加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

django-表单之模型表单渲染(六)

发布时间:2020-12-15 17:08:03 所属栏目:大数据 来源:网络整理
导读:class StudentForms(forms.ModelForm): formats = [ ' %Y-%m-%d ' , %m/%d/%Y = forms.DateField(label= 出生日期 ' ,input_formats= formats) Meta: model = Student # fields='__all__' exclude=['is_deleted'] fields=[ birthday name age ] widgets = {
class StudentForms(forms.ModelForm):
    formats=[
        '%Y-%m-%d',%m/%d/%Y出生日期',input_formats=formats)
     Meta:
        model=Student
        # fields='__all__'
         exclude=['is_deleted']
        fields=[birthdaynameage]
        widgets={
            ':forms.TextInput(attrs={class':custom-textinput})
        }
        help_texts=请输入姓名 error_messages={
             'name':{
                 'required':'...',
                 'min_length':'...',1)">         'max_length':'...',1)">     }
         }
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset=UTF-8">
    <title>{{title}}</title>
    <style>
        .custom-textinput{
            border: 5px solid blue;
            border-radius: 5px;
        }
    </style>
    <link rel=stylesheet" href={% static css/index.css' %}

</head>
<body>
    <!--{% include header.html'%}-->
    <div class=content">
        <!--<h1>这是主界面</h1>-->
        <form action="" method=post">
            <table>
                <!--as_p,as_ul-->
                <!--{{forms.as_table}}-->
                <hr>
                <ul>
                    <li style=list-style-type: none">
                        <span style=color: blue">{{forms.name.label}} : </span>
                        <span>{{forms.name}}</span>
                        <span style=margin-left: 10px">{{forms.name.help_text}}</span>
                    </li>
                </ul>
                <hr>
                <tr>
                    <td><input type=submit" value=" name="></td>
                </tr>
            </table>
        </form>
        <!--{% block content %}-->
        <!--{% endblock %}-->
    </div>
    <!--{% include footer.html'%}-->
</body>
</html>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读