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

前端之家收集整理的这篇文章主要介绍了django-表单之模型表单渲染(六)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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>

猜你在找的Django相关文章