这一篇,将会展示用Python语言实现用户信息的增删改查
首先,先搭建项目框架,这个在上一节里有提到,就不再写
然后 ,搭好项目,就开始编码了,首先,先分析,我们要实现用户信息的管理,就先写好界面,根据界面来写数据库,这里只是实现最简单的用户信息管理,一般有用户名,密码,头像。实现增删改,就是需要三个botton。页面代码展示
登录页面代码`
后台登录
u{
font:14px center;
line-height:50px;
}
.in{
height:30px;
}
log{
margin-top:20px;
width:90px;
height:30px;
font-size:14px;
{% csrf_token %}
用户名:
密 码:
</form>
</center>
这是用户信息列表页面
用户信息
u{
font:14px center;
line-height:50px;
}
.in{
height:30px;
}
.ad{
margin-top:15px;
width:40px;
height:35px;
background-color:#ccc;
{% for res in us%}
ID | 头 像 | 用户名 | 密 码 | 操 作 |
---|---|---|---|---|
{ {res.id}} | |
</td>
<td>{
{res.username}}</td>
<td>{
{res.password}}</td>
<td><a href=/del/{
{res.id}}/>
<input type="button" value="删除">
</a>
<a href=/modify/{
{res.id}}>
<input type="button" value="修改">
</a>
<a href=/img/?id={
{res.id}}>
<input type="button" value="传图">
</a>
<a href='/static/{
{res.img}}'>下载</a>
</td>
</tr>
{%endfor%}
</table>
<a href="/add/">
<input type="button" class="ad" name="add" value="添加"/>
</a>
<a href="/output">
<input type="button" class="ad" name="output" value="导出"/>
</a>
</center>
`这是添加用户信息页面
<!doctype html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta charset="utf-8">
<title>添加用户</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
#u{
font:14px center;
line-height:50px;
}
.in{
height:30px;
}
#log{
margin-top:20px;
width:90px;
height:30px;
font-size:14px;
</style>
</head>
<body>
<center>
<form action="/addinform/" method="post">
{% csrf_token %}<!--模板标签-->
<span id="u">用户名:</span>
<input class="in" type="text"