Django admin and bootstrap 5

django-baton python django

Bootstrap 5 has come, currently in beta release, and seems already very stable.

So the question is: are you looking for a Django admin application based on it?

If yes, then Django Baton V2 is what you're looking for. V2 is a major release of Baton, an admin interface package for Django which has been around since 2017. Currently developed in a specific branch, which is already very stable and used in production in many projects, V2 can be tried in a demo site and installed with pip.

You can try the demo at the following URL: https://django-baton-demo.herokuapp.com
login with username demo and password demo.

You can install it with pip and try it directly in you project:

$ pip install https://github.com/otto-torino/django-baton/archive/v2.zip

Let's see in detail the main features added to Baton V2.

Bootstrap 5

Obviously, as the post title states, Baton V2 is based on Bootstrap 5. The dependency from jQuery has not been dropped, because it's currently used a lot, and Font Awesome 5 is used in place of Bootstrap icons which still lack some stuff.

Django 1.x

Baton V2 drops support for old Django versions and requires Django >= 2.1. If you still need to use it in a previous Django release, you must install Baton V1, the current release is 1.13.2.

Login Page

The login page can now be customized providing a background image which is centered and covers the whole viewport. Also, the toggle password visibility icon was added to the password input field.

# settings.py
  # ...
  'LOGIN_SPLASH': '/static/core/img/login-splash.png',
  # ...

Changelist Filters Includes

Baton V2 adds the possibility to include HTML templates directly inside the changelist filter panel, at the top or the bottom. This functionality is very similar to the other include functionalities:

class NewsAdmin(admin.ModelAdmin):
    baton_cl_filters_includes = [
        ('news/admin_filters_include_top.html', 'top', ),
        ('news/admin_filters_include_bottom.html', 'bottom', )

Changelist Filters Form

This is a nice addition. There's a thing which drives me mad sometimes when using Django admin filters: the fact that they are applied one at a time, and every time the page reloads. With this option, you can turn your filter panel into a filter form. It means that you can set all the filters you desired, and then press a button to submit the search. In order to do that, all "default" filters are rendered as dropdowns. It works also with the Baton InputFilter facility and the well known django-admin-rangefilter package.


Django Baton V2 is a major release which brings in the new Bootstrap 5 CSS framework. It also adds some other nice feature, ane more will probably be added in the next future. It's already very stable and you can try it now!

Subscribe to abidibo.net!

If you want to stay up to date with new contents published on this blog, then just enter your email address, and you will receive blog updates! You can set you preferences and decide to receive emails only when articles are posted regarding a precise topic.

I promise, you'll never receive spam or advertising of any kind from this subscription, just content updates.

Subscribe to this blog

Comments are welcome!

blog comments powered by Disqus

Your Smartwatch Loves Tasker!

Your Smartwatch Loves Tasker!

Now available for purchase!