Home > OS >  How can i change the location of the Django admin search-box?
How can i change the location of the Django admin search-box?

Time:02-22

enter image description here

I want to move the search box and action box on the Django-admin page to the bottom of the page.

I already found the Django-admin change_list.html file, but i don't know how to change it...

How do I do it?

CodePudding user response:

go to dir(Installation route of django)
C:\venvs\Lib\site-packages\django\contrib\admin\templates\admin\change_list.html

Put the two lines in the bottom position.

{% block search %}{% search_form cl %}{% endblock %}
{% block date_hierarchy %}{% if cl.date_hierarchy %}{% date_hierarchy cl %}{% endif %}{% endblock %}

Put the two lines in the bottom position.


<div >

  <!--remove this lines -->
  <!--remove this lines -->
  <!-- {% block search %}{% search_form cl %}{% endblock %}
  {% block date_hierarchy %}{% if cl.date_hierarchy %}{% date_hierarchy cl %}{% endif %}{% endblock %} -->
  <!--remove this lines -->
  <!--remove this lines -->


  <form id="changelist-form" method="post" {% if cl.formset and 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 and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %}
    {% result_list cl %}
    {% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %}
    {% endblock %}
    {% block pagination %}{% pagination cl %}{% endblock %}
  </form>

  <!-- add this lines -->
  <!-- add this lines -->
  {% block search %}{% search_form cl %}{% endblock %}
  {% block date_hierarchy %}{% if cl.date_hierarchy %}{% date_hierarchy cl %}{% endif %}{% endblock %}
  <!-- add this lines -->
  <!-- add this lines -->
</div>
  • Related