Martin
Martin

Reputation: 21

How to change filter panel width in Django admin

I have found anwers how to change column width but not filter width. In my case filter is filled witch just numbers so the Filter pannel could be much more narrow, but how to do it?

Also, since there are a lot of numbers, can I arrange them in several columns (still talking about Filter panel), how?

Django admin example image

Upvotes: 0

Views: 787

Answers (1)

Jaap Joris Vens
Jaap Joris Vens

Reputation: 3560

You can override the Django admin templates and include custom CSS to show the filters any way you want. In your case, you want to customize the changelist.html template which can be found in the Django source code.

First, copy the default changelist.html to yourproject/yourapp/templates/admin/yourapp/yourmodel/changelist.html.

Then, change this template to your liking, for instance:

<div id="changelist-filter" style="columns:2">
  <h2>{% trans 'Filter' %}</h2>
  {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
</div>

More information about overriding admin templates can be found in the Django documentation

Upvotes: 1

Related Questions