(41)-- Django框架之后台商品管理

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Fredreck1919/article/details/79489707

#Django框架之后台商品管理


# index.html

{% extends 'myadmin/index.html' %}
{% block 'body' %}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title  am-cf">商品列表</div>


                </div>
                <div class="widget-body  am-fr">

                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                        <div class="am-form-group">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <button type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 新增</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-secondary"><span class="am-icon-save"></span> 保存</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-warning"><span class="am-icon-archive"></span> 审核</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <form>
                        <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                            <div class="am-form-group tpl-table-list-select">
                                <select name="class" data-am-selected="{btnSize: 'sm'}" style="display: none;">
                                  <option value="title" {% if request.GET.class == 'title' %} selected {% endif %}>商品名称</option>
                                  
                                
                                </select>
                            </div>
                        </div>
                        <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                            <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                <input name="keywords" type="text" value="{{ request.GET.keywords }}" class="am-form-field ">
                                <span class="am-input-group-btn">
                                    <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" ></button>
                                </span>
                            </div>
                        </div>
                    </form>

                    <div class="am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                            <thead>
                                <tr>
                                    <th>商品缩略图</th>
                                    <th>商品名称</th>
                                    <th>所属分类</th>
                                    <th>价格</th>
                                    <th>库存</th>
                                    <th>点击数量</th>
                                    <th>购买数量</th>
                                    <th>状态</th>
                                    <th>时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>

                                {% for v in ulist %}
                                <tr class="gradeX">
                                    <td>
                                        <img src="/static/goods/{{ v.picname }}" class="tpl-table-line-img" alt="">
                                    </td>
                                    <td class="am-text-middle">{{ v.title }}</td>
                                    <td class="am-text-middle">{{ v.pname }}</td>
                                    <td class="am-text-middle">{{ v.price }} 元</td>
                                    <td class="am-text-middle">{{ v.store }}</td>
                                    <td class="am-text-middle">{{ v.clicknum }}</td>
                                    <td class="am-text-middle">{{ v.num }}</td>
                                   
                                    <td class="am-text-middle">
                                        {% if v.state == 1 %}
                                            新发布
                                        {% elif v.state == 2%}
                                            在售
                                        {% else %}
                                            下架
                                        {% endif %}
                                    </td>
                                    <td class="am-text-middle">{{ v.addtime|date:'Y-m-d' }}</td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <a href="{% url 'myadmin_goodsedit' v.id %}">
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                            <a href="{% url 'myadmin_goodsdel' v.id %}" class="tpl-table-black-operation-del">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {% endfor %}

       
                                <!-- more data -->
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">

                        {% load pagetag %}
                          <div class="am-fr">
                              <ul class="am-pagination tpl-pagination">
                               
                                <!-- 如果有上一页则输出 -->
                                {% if ulist.has_previous %}
                                      <li><a href="/admin/goods/index/{{ ulist.previous_page_number }}?{{ where }}">«</a></li>
                                {% endif %}

                                <!-- 循环页码信息 -->
                                {%  for pg in ulist.paginator.page_range %}
                                    <!-- 
                                        ulist.number 为当前页码  4
                                        pg 为当前循环出来的页码数  1 2 3 4 5 6 7 8 9 10
                                     -->
                                    {% circle_page  ulist.number pg '/admin/goods/index/'  where %}

                                {% endfor %}

                                <!-- 如果有下一页则输出 -->
                                {% if ulist.has_next %}
                                  <li class=""><a href="/admin/goods/index/{{ ulist.next_page_number }}?{{ where }}">»</a></li>
                                {% endif %}

                              </ul>
                          </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}


# add.html

{% extends 'myadmin/index.html' %}
{% block 'body' %}

<div class="container-fluid am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
            <div class="page-header-heading"><span class="am-icon-home page-header-heading-icon"></span> 部件首页 <small>Amaze UI</small></div>
            <p class="page-header-description">Amaze UI 含近 20 个 CSS 组件、20 余 JS 组件,更有多个包含不同主题的 Web 组件。</p>
        </div>
        <div class="am-u-lg-3 tpl-index-settings-button">
            <button type="button" class="page-header-button"><span class="am-icon-paint-brush"></span> 设置</button>
        </div>
    </div>

</div>
<div class="row-content am-cf">
    <div class="row">

        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-fl">商品添加表单</div>
                    <div class="widget-function am-fr">
                        <a href="javascript:;" class="am-icon-cog"></a>
                    </div>
                </div>
                <div class="widget-body am-fr">

                    <form action="{% url 'myadmin_goodsinsert' %}" method="post" enctype="multipart/form-data" class="am-form tpl-form-line-form">
                        {% csrf_token %}
                        <div class="am-form-group">
                            <label for="user-phone" class="am-u-sm-3 am-form-label">
                            所属分类</label>
                            <div class="am-u-sm-9">
                                <select name="pid" data-am-selected="{searchBox: 1}" style="display: none;">
                                  {% for v in types %}
                                    {% if v.pid == 0 %}
                                        <option disabled value="{{ v.id }}">{{ v.name }}</option>

                                    {% else %}
                                        <option value="{{ v.id }}">{{ v.name }}</option>
                                    {% endif %}

                                  {% endfor %}
                                </select>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">商品名</label>
                            <div class="am-u-sm-9">
                                <input type="text" name="title" class="tpl-form-input"  placeholder="请输入商品名">
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">生产厂家</label>
                            <div class="am-u-sm-9">
                                <input type="text" name="company" class="tpl-form-input"  placeholder="请输入生产厂家">
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">商品单价</label>
                            <div class="am-u-sm-9">
                                <input type="text" name="price" class="tpl-form-input"  placeholder="请输入商品单价">
                            </div>
                        </div>

                         <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">商品库存</label>
                            <div class="am-u-sm-9">
                                <input type="text" name="store" class="tpl-form-input"  placeholder="请输入商品库存">
                            </div>
                        </div>

                      
                        <div class="am-form-group">
                            <label for="user-weibo" class="am-u-sm-3 am-form-label">商品图片</label>
                            <div class="am-u-sm-9">
                                <div class="am-form-group am-form-file">
                                    <div class="tpl-form-file-img">
                                        <img src="assets/img/a5.png" alt="">
                                    </div>
                                    <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                        <i class="am-icon-cloud-upload"></i> 添加商品图片</button>
                                    <input id="doc-form-file" type="file" name="pic" multiple="">
                                </div>
                            </div>
                        </div>

                        <link rel="stylesheet" type="text/css" href="/ueditor/UE/third-party/SyntaxHighlighter/shCoreDefault.css">
                        <script type="text/javascript" src="/ueditor/UE/third-party/SyntaxHighlighter/shCore.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/ueditor.config.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/ueditor.all.min.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/lang/zh-cn/zh-cn.js"></script>



                        <div class="am-form-group">
                            <label for="user-intro" class="am-u-sm-3 am-form-label">商品描述</label>
                            <div class="am-u-sm-9">
                                <!-- <textarea name="descr" class="" rows="10" id="user-intro" placeholder="请输入商品描述"></textarea> -->
                                <script id="editor" style="color:red" name="descr" type="text/plain" style="height:500px;"></script>
                            </div>
                        </div>


                        <script type="text/javascript">
                            var ue = UE.getEditor('editor');
                            SyntaxHighlighter.all();
                        </script>

                        <div class="am-form-group">
                            <div class="am-u-sm-9 am-u-sm-push-3">
                                <button  class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}


# edit.html

{% extends 'myadmin/index.html' %}
{% block 'body' %}

<div class="container-fluid am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
            <div class="page-header-heading"><span class="am-icon-home page-header-heading-icon"></span> 部件首页 <small>Amaze UI</small></div>
            <p class="page-header-description">Amaze UI 含近 20 个 CSS 组件、20 余 JS 组件,更有多个包含不同主题的 Web 组件。</p>
        </div>
        <div class="am-u-lg-3 tpl-index-settings-button">
            <button type="button" class="page-header-button"><span class="am-icon-paint-brush"></span> 设置</button>
        </div>
    </div>

</div>
<div class="row-content am-cf">
    <div class="row">

        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-fl">商品添加表单</div>
                    <div class="widget-function am-fr">
                        <a href="javascript:;" class="am-icon-cog"></a>
                    </div>
                </div>
                <div class="widget-body am-fr">

                    <form action="{% url 'myadmin_goodsupdate' %}" method="post" enctype="multipart/form-data" class="am-form tpl-form-line-form">
                        {% csrf_token %}
                        <!-- 隐藏域 传递 商品id  -->
                        <input type="hidden" name="gid" value="{{ ginfo.id }}">
                        <div class="am-form-group">
                            <label for="user-phone" class="am-u-sm-3 am-form-label">
                            所属分类</label>
                            <div class="am-u-sm-9">
                                <input value="{{ ginfo.pname }}" type="text" readonly name="" class="tpl-form-input"  placeholder="请输入用户名">
                                
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">商品名</label>
                            <div class="am-u-sm-9">
                                <input type="text" name="title" value="{{ ginfo.title }}" class="tpl-form-input"  placeholder="请输入商品名">
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">生产厂家</label>
                            <div class="am-u-sm-9">
                                <input type="text" name="company"  value="{{ ginfo.company }}"  class="tpl-form-input"  placeholder="请输入生产厂家">
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">商品单价</label>
                            <div class="am-u-sm-9">
                                <input type="text" name="price" value="{{ ginfo.price }}"  class="tpl-form-input"  placeholder="请输入商品单价">
                            </div>
                        </div>

                         <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">商品库存</label>
                            <div class="am-u-sm-9">
                                <input type="text" name="store" value="{{ ginfo.store }}" class="tpl-form-input"  placeholder="请输入商品库存">
                            </div>
                        </div>

                      
                        <div class="am-form-group">
                            <label for="user-weibo" class="am-u-sm-3 am-form-label">商品图片</label>
                            <div class="am-u-sm-9">
                                <div class="am-form-group am-form-file">
                                    <div class="tpl-form-file-img">
                                        <img src="/static/goods/{{ ginfo.picname }}" alt="">
                                    </div>
                                    <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                        <i class="am-icon-cloud-upload"></i> 添加商品图片</button>
                                    <input id="doc-form-file" type="file" name="pic" multiple="">
                                </div>
                            </div>
                        </div>

                        <link rel="stylesheet" type="text/css" href="/ueditor/UE/third-party/SyntaxHighlighter/shCoreDefault.css">
                        <script type="text/javascript" src="/ueditor/UE/third-party/SyntaxHighlighter/shCore.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/ueditor.config.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/ueditor.all.min.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/lang/zh-cn/zh-cn.js"></script>



                        <div class="am-form-group">
                            <label for="user-intro" class="am-u-sm-3 am-form-label">商品描述</label>
                            <div class="am-u-sm-9">
                                <!-- <textarea name="descr" class="" rows="10" id="user-intro" placeholder="请输入商品描述"></textarea> -->
                                <script id="editor" style="color:red" name="descr" type="text/plain" style="height:500px;">
                                    {{ ginfo.descr|safe }}
                                </script>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="user-phone" class="am-u-sm-3 am-form-label">
                            当前状态</label>
                            <div class="am-u-sm-9">
                                <select name="state" data-am-selected="{searchBox: 1}" style="display: none;">
                                        <option value="2">在售</option>
                                        <option value="1">新发布</option>
                                        <option value="3">下架</option>
                                </select>
                            </div>
                        </div>


                        <script type="text/javascript">
                            var ue = UE.getEditor('editor');
                            SyntaxHighlighter.all();
                        </script>

                        <div class="am-form-group">
                            <div class="am-u-sm-9 am-u-sm-push-3">
                                <button  class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}




兄弟连学python


Python学习交流、资源共享群:563626388 QQ


展开阅读全文

没有更多推荐了,返回首页