Python菜鸟成长记——简单实现用户登录和增删改查以及文件上传和下载

这一篇,将会展示用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" 
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值