Django入门(二)

4.创建模板

  • 创建模板能在前端显示页面,在apitest中创建templates文件夹后创建login.html文件,纯HTML5页面,后续详细介绍前端知识
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Login</title>
    </head>
    <body>
    <h1>login</h1>
    <form method="post" action="/login/">
    {% csrf_token %}
    <br> <input name="username" type="text" placeholder="username" >
    <br> <input name="password" type="password" placeholder="password">
    {{ error }}<br>
    <br> <button id="submit" type="submit">submit</button>
    </form>
    </body>
    </html>