zoukankan      html  css  js  c++  java
  • django-admin 修改admin自带模版

    还不知道怎么指定修改每个页面,我就把把所有修改写在一个页面,通过url进行判断是否是是否显示修改内容,修改的是change_form.html
    ,在admin里面可以找到

    {% block object-tools %}
    {% if change %}{% if not is_popup %}
      <ul class="object-tools">
        {% block object-tools-items %}
        <li>
            {% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}
            <a href="{% add_preserved_filters history_url %}" class="historylink">{% trans "History" %}</a>
        </li>
        {% if has_absolute_url %}<li><a href="{{ absolute_url }}" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif %}
        {% endblock %}
      </ul>
    {% endif %}{% endif %}
    {% endblock %}
    <!--根据地址判断是否是添加批量添加公司-->
    {% if 'admin/django_admin/company/add' in request.path %}
        <a href="{% url 'create_company' %}">
            <button style="height: 30px">批量创建单位</button>
        </a>
    {% endif %}
    <!--根据地址判断是否是添加批量添加用户-->
    {% if 'admin/django_admin/profile_user/add' in request.path %}
        <a href="{% url 'create_user' %}">
            <button style="height: 30px">批量创建用户</button>
        </a>
    {% endif %}
    <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form" novalidate>{% csrf_token %}{% block form_top %}{% endblock %}
    <div>
    {% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1" />{% endif %}
    {% if to_field %}<input type="hidden" name="{{ to_field_var }}" value="{{ to_field }}" />{% endif %}
    {% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %}
    {% if errors %}
        <p class="errornote">
        {% if errors|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
        </p>
        {{ adminform.form.non_field_errors }}
    {% endif %}
    

    应该还有更简单的方式,就是直接修改要操作界面,不过django的admin后台界面是拼起来的,这点就很难办了,希望有人指出更好的方法。

  • 相关阅读:
    【C++】不同含义new和delete
    苹果Lion 操作系统还没到成熟时 不及格的程序员
    视图旋转方式 不及格的程序员
    来电归属地 黑名单‘s 不及格的程序员
    dispatch_async 线程分发注意事项. 不及格的程序员
    IEEE printf specification 不及格的程序员
    What is the new iPad retina display? 不及格的程序员
    图形设备接口的起源 不及格的程序员
    windows xp 遭遇administrator账号劫持 不及格的程序员
    What does "not supported" mean? 不及格的程序员
  • 原文地址:https://www.cnblogs.com/wuqingzangyue/p/5457786.html
Copyright © 2011-2022 走看看