国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Django 管理平臺用戶界面編寫

這篇具有很好參考價值的文章主要介紹了Django 管理平臺用戶界面編寫。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

Django 網(wǎng)頁公共部分編寫

前言:目前還在學(xué)習(xí)中,這是第一個嘗試的項目,多有不足,感謝大家的觀看與批評。

目標(biāo):

Django 管理平臺用戶界面編寫,django,python,后端,前端

一. 前端頁面

這次沒找到前輩的模板,自行編寫base.html和base.css

<!DOCTYPE html>
<html lang="zh-CN">
{% load static %}
<head>
    <meta charset="UTF-8">
    <title>用戶界面</title>
    <link rel="stylesheet" type="text/css" href="{% static 'base/scripts/svg_img/iconfont.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'base/css/base.css' %}">
</head>
<body>
    {# 上方基本信息展示 #}
    <nav class="nav_top">
        <div class="leftNav iconfont">&#xe673;&nbsp刷票管理平臺</div>
        <div class="rightSvg iconfont">&#xe60f;</div>
        <div class="rightNav">zcc</div>
    </nav>

    {# 下方主要內(nèi)容部分 #}
    <div class="main_content">
        <div class="mainDiv">
            {# 左邊導(dǎo)航欄 #}
            <div class="leftDiv">
                <div class="iconfont">&#xe74a; 用戶信息</div>
                <ul class="user_info" style="margin-bottom: 0">
                    <a href="#"><li>個人資料</li></a>
                    <a href="#"><li>我的交易</li></a>
                </ul>
                <div class="iconfont">&#xe600; 平臺分類</div>
                <ul class="plat_type">
                    <a href="#"><li>央視頻</li></a>
                    <a href="#"><li>B站完播</li></a>
                    <a href="#"><li>B站播放量(30%~50%完播)</li></a>
                </ul>
            </div>

            {# 右側(cè)用戶操作內(nèi)容展示,這里是上方的小字導(dǎo)航欄和右側(cè)、下側(cè)的滑塊部分 #}
            <div class="rightDiv">
                <div class="infor">
                </div>
                <div class="information">
                </div>
            </div>
        </div>
    </div>
</body>
</html>
* {
    margin: 0;
    padding: 0;
}

/*頂部基本信息展示部分*/
.nav_top {
    background-color: #2f72ab;
    width: 100%;
    height: 60px;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    position: fixed;
}

/*左部導(dǎo)航欄*/
.leftNav {
    float: left;
    height: 20px;
    padding-left: 40px;
    padding-top: 20px;
    font-family: Microsoft YaHei;
    color: white;
}

/*右側(cè)用戶操作內(nèi)容部分*/
.rightNav {
    float: right;
    height: 20px;
    padding-top: 20px;
    font-family: Microsoft YaHei;
    color: white;
}

.rightSvg {
    float: right;
    height: 40px;
    line-height: 40px;
    font-size: 36px;
    padding-right: 40px;
    padding-top: 10px;
    color: white;
}

.main_content {
    width: 100%;
    height: calc(100vh - 60px);
    display: flex;
    flex-flow: column nowrap;
}

.mainDiv {
    margin-top: 60px;
    flex: 1;
}

/*去除左側(cè)導(dǎo)航欄所有超鏈接的下劃線*/
.main_content .mainDiv .leftDiv ul a:hover {
    text-decoration: none;
}

.leftDiv {
    float: left;
    width: calc(20% - 6px);
    height: calc(100vh - 60px);;
    background-color: #eaedf1;
}

.leftDiv div {
    background-color: #f5f5f5;
    padding-left: 10px;
    height: 40px;
    line-height: 40px;
}

.leftDiv li {
    background-color: #fff;
    padding-left: 30px;
    height: 30px;
    line-height: 30px;
    color: #2f72ab;
}

.rightDiv {
    float: left;
    width: 80%;
    height: calc(100vh - 60px);
    margin-left: 5px;
    overflow: scroll;
    border-left: #e8e8e8 solid 1px;
}

/*用戶操作部分上方導(dǎo)航*/
.infor {
    width: 100%;
    height: 30px;
    background-color: #f5f5f5;
    padding-left: 20px;
    line-height: 30px;
}

.infor ul li {
    display: inline-block;
    list-style-type: none;
}

.infor ul li a {
    color: black;
}

.infor ul li a:hover {
    text-decoration: none;
}

/*右側(cè)上方小導(dǎo)航部分,最后一部分文字顏色不一樣*/
.infor ul li a:last-child {
    color: #828282;
}

.information {
    width: 100%;
}

注意:

1.? 矢量圖下載與使用:iconfont-阿里巴巴矢量圖標(biāo)庫,按照官網(wǎng)流程操作。

2.? 注意margin的使用——相鄰塊元素合并嵌套塊元素塌陷。建議多用padding。

Django 管理平臺用戶界面編寫,django,python,后端,前端

3. CSS各個單位的區(qū)別:px、pt、em、rem、vh、vw。參考前輩文章常見CSS單位總結(jié)_css 相對單位-CSDN博客

4. 自動填充頁面剩余部分:使用Flex布局 - - > 參考前輩文章Flex布局詳解-CSDN博客

二. Django前端調(diào)整

添加?{% block style %}{% endblock %}?用于其他頁面添加CSS代碼;使用?{{ title }}?用于不同的標(biāo)題, {{ username }} 同理。

<head>
    <meta charset="UTF-8">
    <title>{{ title }}</title>
    <link rel="stylesheet" type="text/css" href="{% static 'base/scripts/svg_img/iconfont.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'base/css/base.css' %}">
    {% block style %}{% endblock %}
</head>
<body>

<nav class="nav_top">
    <div class="leftNav iconfont">&#xe673;&nbsp刷票管理平臺</div>
    <div class="rightSvg iconfont">&#xe60f;</div>
    <div class="rightNav">{{ username }}</div>
</nav>

用戶操作部分:

{% block spans %}{% endblock %} 用于修改上方小導(dǎo)航;{% block information %}{% endblock %} 用于添加主題內(nèi)容。

<div class="rightDiv">
    <div class="infor">
        {% block spans %}
        {% endblock %}
    </div>
    <div class="information">
        {% block information %}
        {% endblock %}
    </div>
</div>

至此結(jié)束。

Django 用戶資料界面編寫

目標(biāo):

Django 管理平臺用戶界面編寫,django,python,后端,前端

一. 前端頁面

引入公共部分 base.html

{% extends 'base_html/base.html' %}

引入CSS文件和Bootstrap

{% load static %}

{% block style %}
    <link  rel="stylesheet" id="bootstrap-css">
    <link rel="stylesheet" type="text/css" href="{% static 'user/css/user.css' %}">
{% endblock %}

右側(cè)上方小導(dǎo)航部分:

{% block spans %}
    <ul>
        <li>
            <a href="#"><span>用戶信息</span></a>
            <span>/</span>
        </li>
        <li>
            <a href="#"><span>個人資料</span></a>
        </li>
    </ul>
{% endblock %}

右側(cè)主體部分:

{% block information %}
    {# 左側(cè)用戶資料 #}
    <div class="myInfo">
        <div class="iconfont">&#xe74a; 我的資料</div>
        <div>
            <table>
                <tbody>
                <tr>
                    <td>用戶名</td>
                    <td>{{ username }}</td>
                </tr>
                <tr>
                    <td>賬戶余額</td>
                    <td>{{ balance }}</td>
                </tr>
                <tr>
                    <td>注冊時間</td>
                    <td>{{ regTime }}</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>

    {# 右側(cè)修改密碼 #}
    <div class="pwdChange">
        <div class="iconfont">&#xe62e; 修改密碼</div>
        <div>
            <form id="pwd-form" method="post" role="form" novalidate>
                {% csrf_token %}
                <table>
                    <tbody>
                    <tr>
                        <td>密碼</td>
                        <td>{{ form.enterPwd }}</td>
                    </tr>
                    <tr>
                        <td>確認(rèn)密碼</td>
                        <td>{{ form.ensurePwd }}</td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <button type="submit" class="form-control">提交</button>
                            <span class="error_massage">
                                {{ form.ensurePwd.errors }}
                            </span>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>
        </div>
    </div>
{% endblock %}

CSS代碼:

/*左側(cè)導(dǎo)航欄左邊裝飾效果*/
.leftDiv .user_info > a:first-child li {
    border-left: #2f72ab solid 5px;
    padding-left: 25px;
}

/*Flex布局*/
.information{
    display: flex;
    flex-flow: row nowrap;
    justify-content: space-between;
}

.information .myInfo{
    margin-left: 25px;
    width: 47%;
    margin-top: 25px;
    height: 250px;
}

.information .pwdChange{
    margin-right: 25px;
    width: 47%;
    margin-top: 25px;
    height: 250px;
}

/*左側(cè)用戶資料*/
/*上面的名字*/
.information .myInfo div:first-child{
    width: 100%;
    height: 50px;
    border: #eaedf1 solid 2px;
    background-color: #f5f5f5;
    line-height: 50px;
    padding-left: 20px;
    font-weight: bold;
}

.information .myInfo div:last-child{
    width: 100%;
    height: 200px;
    border: #eaedf1 solid 2px;
    border-top: #eaedf1 solid 0;
}

.information .myInfo div table{
    padding-top: 20px;
    padding-left: 36px;
    border-collapse: initial;
}

.information .myInfo div table tr td{
    padding: 10px;
}

.information .myInfo div table tr td:first-child{
    text-align: right;
    font-weight: bold;
}

/*右側(cè)·修改密碼*/
.information .pwdChange div:first-child{
    width: 100%;
    height: 50px;
    border: #eaedf1 solid 2px;
    background-color: #f5f5f5;
    line-height: 50px;
    padding-left: 20px;
    font-weight: bold;
}

.information .pwdChange div:last-child{
    width: 100%;
    height: 200px;
    border: #eaedf1 solid 2px;
    border-top: #eaedf1 solid 0;
}

.information .pwdChange div table{
    padding-top: 20px;
    padding-left: 36px;
    border-collapse: initial;
}

.information .pwdChange div table tr td{
    padding: 10px;
}

.information .pwdChange div table tr td:first-child{
    text-align: right;
    font-weight: bold;
}

.information .pwdChange div table tr button{
    width: 27%;
    height: 30px;
    line-height: 5px
}

.error_massage li{
    color: red;
    list-style-type: none;
    padding-top: 5px;
}

二. Django后端各種py文件

urls.py:

int:id 用于傳輸?shù)卿浻脩舻膇d,便于后續(xù)查詢數(shù)據(jù)庫。

name:"user_view"?方便后續(xù)跳轉(zhuǎn)網(wǎng)頁。

path('user/<int:id>/', user_views.user, name="user_view"),

views.py:

和上一篇博客的login差不多,但存在問題,即修改密碼后刷新瀏覽器會出現(xiàn)警告“新密碼不應(yīng)該與舊密碼相同”

class pwdForm(forms.Form):
    # 輸入新密碼
    enterPwd = forms.CharField(
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': "請輸入密碼", 'style': "width: 200%"}),
        error_messages={"required": "該字段不能為空"},
        label='輸入密碼'
    )

    # 確認(rèn)密碼
    ensurePwd = forms.CharField(
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': "請確認(rèn)密碼", 'style': "width: 200%"}),
        error_messages={"required": "該字段不能為空"},
        label='確認(rèn)密碼'
    )

def user(request, **kwargs):
    # 獲取數(shù)據(jù)庫數(shù)據(jù)
    user_id = kwargs.get('id')
    user_info = User.objects.get(id=user_id)

    username = user_info.name
    oldPwd = user_info.pwd
    balance = user_info.balance
    regTime = user_info.regTime

    if request.method == "GET":
        form = pwdForm()
        return render(request, 'user_html/user.html',
                      {"form": form, "title": "用戶界面", "username": username, "balance": balance, "regTime": regTime,
                       "userId": user_id})

    elif request.method == 'POST':
        form = pwdForm(request.POST)
        if form.is_valid():
            # 輸入新密碼
            enterPwd = form.cleaned_data['enterPwd']
            # 確認(rèn)密碼
            ensurePwd = form.cleaned_data['ensurePwd']

            if enterPwd == ensurePwd and enterPwd != oldPwd:
                User.objects.filter(id=user_id).update(pwd=enterPwd)
                form.add_error("ensurePwd", "密碼修改成功")
                return render(request, "user_html/user.html",
                              {"form": form, id: user_id, "title": "用戶界面", "username": username, "balance": balance,
                               "regTime": regTime, "userId": user_id})

            # 瀏覽器刷新后自動提交表單導(dǎo)致出現(xiàn)"新密碼不應(yīng)該與舊密碼相同"提醒
            elif enterPwd == ensurePwd and enterPwd == oldPwd:
                form.add_error("ensurePwd", "新密碼不應(yīng)該與舊密碼相同")
                return render(request, "user_html/user.html",
                              {"form": form, id: user_id, "title": "用戶界面", "username": username, "balance": balance,
                               "regTime": regTime, "userId": user_id})

            else:
                form.add_error("ensurePwd", "兩次密碼不一致")
                return render(request, "user_html/user.html",
                              {"form": form, id: user_id, "title": "用戶界面", "username": username, "balance": balance,
                               "regTime": regTime, "userId": user_id})
    else:
        form = pwdForm()

        return render(request, 'user_html/user.html',
                      {"form": form, "title": "用戶界面", "username": username, "balance": balance, "regTime": regTime,
                       "userId": user_id})

Django交易界面編寫

目標(biāo):

Django 管理平臺用戶界面編寫,django,python,后端,前端

一. 前端頁面

使用bootstrap即可,沒什么注意點。

二. Django分頁器Paginator

此處參考了這位前輩的文章:Django 使用Paginator分頁器_django paginator-CSDN博客

from django.core.paginator import Paginator

2.0?創(chuàng)建數(shù)據(jù)庫

class Transaction(models.Model):
    ACTION_STATES = {
        "Y": "已執(zhí)行",
        "N": "待執(zhí)行"
    }

    username = models.CharField(verbose_name='用戶名', max_length=32)
    actionDate = models.DateField(verbose_name='交易日期', auto_now=True)
    actionNumber = models.CharField(verbose_name='訂單號', max_length=32, default="")
    aimUrl = models.CharField(verbose_name='目標(biāo)URL', max_length=256)
    actionAmount = models.IntegerField(verbose_name='刷單數(shù)量', default=0)

    # 最大數(shù)位為5,小數(shù)點后保留兩位小數(shù)
    originalPrice = models.DecimalField(verbose_name='原價', max_digits=5, decimal_places=2, default=0.00)
    deductionPrice = models.DecimalField(verbose_name='折扣價', max_digits=5, decimal_places=2, default=0.00)

    originalBroadcast = models.CharField(verbose_name="原播放量", max_length=32, default="0")
    actionState = models.CharField(verbose_name="狀態(tài)", max_length=1, choices=ACTION_STATES, default="N")
    note = models.CharField(verbose_name="備注", max_length=128, default="測試")

注意點:

(1). choices

ACTION_STATES = {
        "Y": "已執(zhí)行",
        "N": "待執(zhí)行"
    }

actionState = models.CharField(verbose_name="狀態(tài)", max_length=1, choices=ACTION_STATES, default="N")

方便操作,后續(xù)使用時,object.actionState = "Y",?object.get_actionState_display = "已執(zhí)行"。

(2). 保留兩位小數(shù)

originalPrice = models.DecimalField(verbose_name='原價', max_digits=5, decimal_places=2, default=0.00)

max_digits=5:最大數(shù)位為5;decimal_places=2:保留兩位小數(shù)。

2.1 創(chuàng)建實例

order_info = Transaction.objects.filter(username=username)

paginator = Paginator(order_info, 10) # 數(shù)據(jù)來源為order_info,每頁最多十行數(shù)據(jù)

page = request.GET.get('page', 1)  # 獲取當(dāng)前請求的頁碼,默認(rèn)為第一頁

currentData = paginator.get_page(page) # 獲取第一頁的數(shù)據(jù),傳遞到前端頁面

前端代碼:

<tbody>
{% for order in currentDate %}
    <tr>
        <td>{{ order.actionDate }}</td>
        <td>{{ order.actionNumber }}</td>
        <td>{{ order.aimUrl }}</td>
        <td>{{ order.actionAmount }}</td>
        <td>¥{{ order.originalPrice }}</td>
        <td>¥{{ order.deductionPrice }}</td>
        <td>{{ order.originalBroadcast }}</td>
        <td>{{ order.get_actionState_display }}</td>
        <td>{{ order.note }}</td>
    </tr>
{% endfor %}
</tbody>

分頁效果:

<ul class="pagination">
    {% if order_list.has_previous %}
    <li class="page-item"><a class="page-link" href="?id={{ currentData.previous_page_number }}">上一頁</a></li>
    {% else %}
    <li class="page-item disabled"><a class="page-link" href="#">上一頁</a></li>
    {% endif %}

    {# ... #}
</ul>

2.3 優(yōu)化

def YSP(request, **kwargs):
    user_id = kwargs.get('id')
    user_info = User.objects.get(id=user_id)
    username = user_info.name

    # 獲取分頁數(shù)據(jù)
    order_info = Transaction.objects.filter(username=username)

    # 創(chuàng)建實例
    orderPaginator = Paginator(order_info, 10)
    currentPage = int(request.GET.get("id", 1))

    # 當(dāng)數(shù)據(jù)大于10頁時,頁面只顯示10頁
    if orderPaginator.num_pages > 15:
        if currentPage - 5 < 1:
            pageRange = range(1, 11)
        elif currentPage + 5 > orderPaginator.num_pages:
            pageRange = range(currentPage - 5, orderPaginator.num_pages)
        else:
            pageRange = range(currentPage - 5, currentPage + 5)
    else:
        pageRange = orderPaginator.page_range

    # 分頁器id超出范圍時返回第一面或最后一面
    try:
        order_list = orderPaginator.page(currentPage)
    except PageNotAnInteger:
        order_list = orderPaginator.page(1)
    except EmptyPage:
        order_list = orderPaginator.page(orderPaginator.num_pages)

    return render(request, "user_html/YSP.html", {"userId": user_id,
                                                  "username": username,
                                                  "order_list": order_list,
                                                  "paginator": orderPaginator,
                                                  "page_range": pageRange,
                                                  "currentPage": currentPage,
                                                  "title": "平臺分類"})

前端代碼:

<table class="table table-bordered">
    <thead>
    <tr>
        <th>日期</th>
        <th>訂單號</th>
        <th>URL</th>
        <th>數(shù)量</th>
        <th>原價</th>
        <th>折扣價</th>
        <th>原播放量</th>
        <th>狀態(tài)</th>
        <th>備注</th>
        <th>刪除</th>
    </tr>
    </thead>

    <tbody>

    {% for order in order_list %}
        <tr>
            <td>{{ order.actionDate }}</td>
            <td>{{ order.actionNumber }}</td>
            <td>{{ order.aimUrl }}</td>
            <td>{{ order.actionAmount }}</td>
            <td>¥{{ order.originalPrice }}</td>
            <td>¥{{ order.deductionPrice }}</td>
            <td>{{ order.originalBroadcast }}</td>
            <td>{{ order.get_actionState_display }}</td>
            <td>{{ order.note }}</td>
            <td>
                <form method="GET" action="./deleteOrder/">
                    {% csrf_token %}
                    <input type="hidden" name="order_actionNumber" value="{{ order.actionNumber }}">
                    <button type="submit" class="btn btn-danger btn-xs">刪除</button>
                </form>
            </td>
        </tr>
    {% endfor %}

    </tbody>

</table>

<nav class="d-flex justify-content-center" aria-label="Page navigation example">
    <ul class="pagination">

        {% if order_list.has_previous %}
            <li class="page-item"><a class="page-link" href="?id={{ order_list.previous_page_number }}">上一頁</a>
            </li>
        {% else %}
            <li class="page-item disabled"><a class="page-link" href="#">上一頁</a></li>
        {% endif %}

        {% for item in page_range %}
            {% if item == currentPage %}
                <li class="page-item active"><a class="page-link" href="?id={{ item }}">{{ item }}</a></li>
            {% else %}
                <li class="page-item"><a class="page-link" href="?id={{ item }}">{{ item }}</a></li>
            {% endif %}
        {% endfor %}

        {% if order_list.has_next %}
            <li class="page-item"><a class="page-link" href="?id={{ order_list.next_page_number }}">下一頁</a></li>
        {% else %}
            <li class="page-item disabled"><a class="page-link" href="#">下一頁</a></li>
        {% endif %}

        <li class="page-item">
            <span class="page-link" id="stataData"
                  style="color: #828282">共 {{ paginator.count }} 條數(shù)據(jù), 頁碼{{ currentPage }}/{{ paginator.num_pages }}頁</span>
        </li>
    </ul>
</nav>

2.4 實際效果

Django 管理平臺用戶界面編寫,django,python,后端,前端

三. 添加與刪除訂單

目標(biāo)頁面:

Django 管理平臺用戶界面編寫,django,python,后端,前端

Django 管理平臺用戶界面編寫,django,python,后端,前端

后端代碼:

def createOrder(request, **kwargs):
    user_id = kwargs.get('id')
    user_info = User.objects.get(id=user_id)
    username = user_info.name

    if request.method == 'POST':
        form = CORForm(request.POST)
        if form.is_valid():
            aimUrl = form.cleaned_data['aimUrl']
            actionAmount = form.cleaned_data['actionAmount']
            note = form.cleaned_data['note']
            actionNumber = ''.join(str(random.randint(0, 9)) for _ in range(22))
            originalPrice = 0.0004 * actionAmount
            Transaction.objects.create(username=username, actionNumber=actionNumber, aimUrl=aimUrl,actionAmount=actionAmount, originalPrice=originalPrice, note=note)
            return redirect("YSP", id=user_id)
    else:
        form = CORForm()
        return render(request, "user_html/createOrder.html",
                      {"userId": user_id, "username": username, "form": form, "title": "平臺分類"})


def deleteOrder(request, **kwargs):
    user_id = kwargs.get('id')
    user_info = User.objects.get(id=user_id)
    username = user_info.name

    if request.method == 'POST':
        delete_actionNumber = request.POST.get("order_actionNumber")
        order_info = Transaction.objects.get(actionNumber=delete_actionNumber)
        order_info.delete()
        return redirect("YSP", id=user_id)
    else:
        delete_actionNumber = request.GET.get("order_actionNumber")
        order_info = Transaction.objects.get(actionNumber=delete_actionNumber)
        return render(request, "user_html/deleteOrder.html",
                      {"userId": user_id, "username": username, "order": order_info, "title": "平臺分類"})

普通的增加 Transaction.objects.create() 和

刪除 Transaction.objects.get(actionNumber=delete_actionNumber).delete() 。

四. 交易記錄頁面

Django 管理平臺用戶界面編寫,django,python,后端,前端

創(chuàng)建數(shù)據(jù)庫

class Operation(models.Model):
    OPERATIONS = {
        "D": "刪除訂單",
        "C": "創(chuàng)建訂單",
        "O": "執(zhí)行訂單",
    }
    NOTES = {
        "Y": "央視頻播放",
        "B": "B站播放",
        "T": "B站30%播放",
    }

    username = models.CharField(verbose_name='用戶名', max_length=32, default="")
    actionNumber = models.CharField(verbose_name='訂單號', max_length=32, default="")
    transactionAmountSign = models.CharField(verbose_name='交易金額正負(fù)', max_length=1, default="+")
    transactionAmount = models.DecimalField(verbose_name='交易金額', max_digits=5, decimal_places=2, default=0.00)
    operator = models.CharField(verbose_name='操作員', max_length=32, default="-")
    actionDate = models.DateField(verbose_name='交易日期', auto_now=True)
    operation = models.CharField(verbose_name='操作類型', max_length=1, choices=OPERATIONS)
    note = models.CharField(verbose_name="備注", max_length=1, choices=NOTES)

后端代碼編寫:

由于分頁器用得比較多,所以包裝成函數(shù)

def makePagination(data_list, request):
    from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage

    Paginator = Paginator(data_list, 10)
    currentPage = int(request.GET.get("id", 1))

    if Paginator.num_pages > 15:
        if currentPage - 5 < 1:
            pageRange = range(1, 11)
        elif currentPage + 5 > Paginator.num_pages:
            pageRange = range(currentPage - 5, Paginator.num_pages)
        else:
            pageRange = range(currentPage - 5, currentPage + 5)
    else:
        pageRange = Paginator.page_range

    try:
        page_list = Paginator.page(currentPage)
    except PageNotAnInteger:
        page_list = Paginator.page(1)
    except EmptyPage:
        page_list = Paginator.page(Paginator.num_pages)

    page_list = {"page_list": page_list, "Paginator": Paginator, "pageRange": pageRange, "currentPage": currentPage}
    return page_list
def transaction(request, **kwargs):
    user_id = kwargs.get('id')
    user_info = User.objects.get(id=user_id)
    username = user_info.name
    operation_info = Operation.objects.filter(username=username)

    page_list = makePagination(operation_info, request)

    return render(request, "user_html/transaction.html", {"userId": user_id,"username": username,"operation_list": page_list['page_list'],"paginator": page_list['Paginator'],"page_range": page_list['pageRange'],"currentPage": page_list['currentPage'],"title": "交易記錄"})

關(guān)于頂部快速篩選的button,先欠著,以后再補文章來源地址http://www.zghlxwxcb.cn/news/detail-846462.html

到了這里,關(guān)于Django 管理平臺用戶界面編寫的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Xamarin.Android | 界面跳轉(zhuǎn)到手機自帶的自啟動管理界面,引導(dǎo)用戶將APP加入自啟動

    Xamarin.Android | 界面跳轉(zhuǎn)到手機自帶的自啟動管理界面,引導(dǎo)用戶將APP加入自啟動

    很多 Android 應(yīng)用需要在后臺運行,以便提供實時通知、定時任務(wù)等服務(wù),但是部分 Android 系統(tǒng)通過限制應(yīng)用程序后臺運行,以降低電池消耗和提高系統(tǒng)性能。這就可能導(dǎo)致應(yīng)用程序運行不穩(wěn)定,通知延遲,定時任務(wù)無法正常執(zhí)行等問題。因此,在某些情況下,將應(yīng)用程序添加

    2024年02月16日
    瀏覽(24)
  • Django web 開發(fā)(四) - Django項目實踐(四)-用戶管理

    Django web 開發(fā)(四) - Django項目實踐(四)-用戶管理

    向用戶數(shù)據(jù)表中插入幾行數(shù)據(jù)方便后面進行測試 修改 myproject/myproject/urls.py 修改 myproject/employee_management/views.py 新建 myproject/employee_management/templates/user_list.html 注意: HTML 中獲取數(shù)據(jù)的方式與 Python 中有些不同 例如: 1.HTML中引入函數(shù)不能帶括號, obj.get_gender_display() 2.日期類型轉(zhuǎn)字

    2023年04月22日
    瀏覽(19)
  • Django搭建圖書管理系統(tǒng)03:編寫博客文章的Model模型

    Django搭建圖書管理系統(tǒng)03:編寫博客文章的Model模型

    Django 框架主要關(guān)注的是模型(Model)、模板(Template)和視圖(Views),稱為MTV模式。 它們各自的職責(zé)如下: 層次 職責(zé) 模型(Model),即數(shù)據(jù)存取層 處理與數(shù)據(jù)相關(guān)的所有事務(wù): 如何存取、如何驗證有效性、包含哪些行為以及數(shù)據(jù)之間的關(guān)系等。 模板(Template),即業(yè)務(wù)邏

    2024年02月12日
    瀏覽(29)
  • 【基于Django框架的在線教育平臺開發(fā)-02】用戶注冊功能開發(fā)

    【基于Django框架的在線教育平臺開發(fā)-02】用戶注冊功能開發(fā)

    用戶數(shù)據(jù)表如下所示: Field Type Extra id int Prime Key Auto Increment password varchar(128) last_login datetime(6) Allow Null is_superuser tinyint(1) username varchar(150) first_name varchar(150) last_name varchar(150) email varchar(254) is_staff tinyint(1) is_active tinyint(1) date_joined datetime(6) nick_name varchar(50) birthday date Allow Null

    2024年02月11日
    瀏覽(17)
  • Django 框架添加管理員,完成對普通用戶信息管理

    Django 框架添加管理員,完成對普通用戶信息管理

    前情回顧:Django框架 完成用戶登錄注冊 一般管理員都是直接指定,不開放頁面注冊,可以直接手動在數(shù)據(jù)庫添加,Django框架提供了方法,讓我們直接創(chuàng)建管理員,步驟如下: 打開pycharm下面的命令行終端 輸入命令 按照提示進行輸入信息 打開數(shù)據(jù)庫,可以看出,已經(jīng)幫我們插

    2024年01月16日
    瀏覽(22)
  • python+django+mysql項目實踐三(用戶管理)

    python+django+mysql項目實踐三(用戶管理)

    Pycharm 開發(fā)環(huán)境 Django 前端 MySQL 數(shù)據(jù)庫 Navicat 數(shù)據(jù)庫管理

    2024年02月14日
    瀏覽(31)
  • 用戶界面設(shè)計和評估:如何設(shè)計具有吸引力、易用性和可靠性的用戶界面?

    作者:禪與計算機程序設(shè)計藝術(shù) 用戶界面(User Interface)是一個給用戶提供服務(wù)或者產(chǎn)品的系統(tǒng)界面,通過人機交互、信息呈現(xiàn)、文字表達、圖形符號等表現(xiàn)形式進行溝通,幫助用戶更好的使用產(chǎn)品或服務(wù)。它對于提升企業(yè)的品牌影響力、增加客戶黏性、改善用戶體驗、降低

    2024年02月13日
    瀏覽(27)
  • 【Django+Vue】英文成績管理平臺--20230727

    【Django+Vue】英文成績管理平臺--20230727

    能夠滿足大部分核心需求(標(biāo)綠):報表部分應(yīng)該比較難。 前端編譯 https://gitlab.com/m7840/toeic_vue_dist Vue源碼 https://gitlab.com/m7840/toeic_vue Django源碼 https://gitlab.com/m7840/toeic_python 學(xué)員界面:前后端分離 管理員界面:前后端不分離 1. vue.js的坑 Django的vue.js用axios請求數(shù)據(jù),只適用于

    2024年02月14日
    瀏覽(15)
  • 前端用戶體驗設(shè)計:創(chuàng)造卓越的用戶界面和交互

    前端用戶體驗設(shè)計:創(chuàng)造卓越的用戶界面和交互

    ?? 個人網(wǎng)站:【工具大全】【游戲大全】【神級源碼資源網(wǎng)】 ?? 前端學(xué)習(xí)課程:??【28個案例趣學(xué)前端】【400個JS面試題】 ?? 尋找學(xué)習(xí)交流、摸魚劃水的小伙伴,請點擊【摸魚學(xué)習(xí)交流群】 用戶體驗(User Experience,UX)是前端開發(fā)中至關(guān)重要的一環(huán)。一個優(yōu)秀的用戶體驗

    2024年02月04日
    瀏覽(17)
  • ImageJ 用戶手冊——第四部分(ImageJ用戶界面)

    ImageJ 用戶手冊——第四部分(ImageJ用戶界面)

    與大多數(shù)圖像處理程序不同,ImageJ沒有主工作區(qū)。ImageJ的主窗口實際上相當(dāng)簡潔,只包含一個菜單欄(位于Mac屏幕頂部),其中包含所有菜單命令、工具欄、狀態(tài)欄和進度欄。圖像、直方圖、配置文件、窗口小部件等顯示在附加窗口中。測量結(jié)果顯示在結(jié)果表中。大多數(shù)窗口

    2024年02月10日
    瀏覽(41)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包