code:
# admin.py
class BindBillAdmin(admin.ModelAdmin): def has_delete_permission(self, request, obj=None): # 编辑页面禁用删除按钮 return False def has_add_permission(self, request, obj=None): # 编辑页面禁用 add 按钮 return False # @csrf_protect_m def changelist_view(self, request, extra_context=None): extra_context = { "anchor_bill_total": 232131, "agent_earn": 2313131, } return super(BindBillAdmin, self).changelist_view(request, extra_context=extra_context) change_list_template = "change_list_custom.html" # my_change_list_template
# change_list_custom.html(use django-simpleui)
{% extends "admin/change_list.html" %} {% load i18n admin_urls static admin_list %} {% block content %} <style> #content { position: relative; } .object-tools { position: absolute; top: 16px; right: 20px; height: 50px; z-index: 2; } .object-tools .import_link, .object-tools .export_link { color: white !important; } </style> {% block object-tools %} <ul class="object-tools"> {% block object-tools-items %} {% if has_add_permission %} {{ block.super }} {% endif %} {% endblock %} </ul> {% endblock %} <div id="content-main"> {% if cl.formset.errors %} <p class="errornote"> {% if cl.formset.total_error_count == 1 %}{% trans "Please correct the error below." %}{% else %} {% trans "Please correct the errors below." %}{% endif %} </p> {{ cl.formset.non_form_errors }} {% endif %} <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist"> {% block search %}{% search_form cl %}{% endblock %} {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %} <form id="changelist-form" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %} novalidate>{% csrf_token %} {% if cl.formset %} <div>{{ cl.formset.management_form }}</div> {% endif %} {% block result_list %} {# {% if action_form %}#} {% admin_actions %} {# {% endif %}#} {% result_list cl %} {% endblock %} {% block pagination %}{% pagination cl %}{% endblock %} </form> <div style="float: right;margin-right: 20px;"> <p>主播累计流水:{{ anchor_bill_total }} <br> 代理累计收益:{{ agent_earn }} </p> </div> </div> </div> <script type="text/javascript"> $(".object-tools").hide().find('li a').each(function () { _action.exts.push({ name: $(this).text(), url: $(this).attr('href') }) }) </script> {% endblock %}
show:
Zhuoyuebiji ( 广东·深圳 )
🚩成长的时候,能帮有需要的你
我是 卓越笔记,软件测试工作者,热爱互联网,喜欢琢磨,遇到问题就一定要找到答案。我的博客主要记录学习中遇到的知识点和遇到的问题及问题的解决方法。欢迎同样热爱互联网的小伙伴们交换友链,一起探索互联网的世界 😊
为向您提供更好的服务,我们使用 Cookies。更多相关信息请查阅我们的 隐私政策 和 免责声明