/ WEB APPLICATIONS, BATON

Baton 2 is out

We’ve just released a new major version of django baton: 2.0.0

Bootstrap 5 has come at the end of 2020, and Baton immediately adopted it in its feature branch v2. After testing it also in many production applications for a couple of months, we decided to release a new major version because it turned out to be very very stable.

With the introduction of bootstrap 5 we also changed the overall graphics style and the primary and secondary colors. Baton v2 follows a minimalistic approach, we got rid of many borders and backgrounds, resulting in a cleaner interface.

We also fixed some bugs, enhanced the developer tools and added some new interesting features.

Login splash

In Baton v2 you can configure a login spash image path. Such image is used as a background which covers the whole viewport. It is centered in the available space.

BATON = {
    # ...
    'LOGIN_SPLASH': '/static/core/img/login-splash.png',
    # ...
}

Changelist filters include

We added the possibility to include custom templates in the changelist filter section, at the top or the bottom.

django-baton changelist filters include

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

Collapsable user area

If you need a more compact sidebar menu, you can use this option to collapse the user area (avatar and links).

BATON = {
    # ...
    'COLLAPSABLE_USER_AREA': True,
    # ...
}

Changelist filters form

With this option you can control the changeslist filters functionality. Django’s default functionality lets you filter one field at a time, every time you select a filter the page is suddendly reloaded applying the new filter. It means that if you want to apply many filters you’ll reload the page multiple times because you need to apply one filter at a time. With the new option introduced in Baton v2 you can change this behaviour: the changelist filter section behaves like a form. You can apply all the filters at one and finally click a “filter” button which applies them.

BATON = {
    # ...
    'CHANGELIST_FILTERS_FORM': True,
    # ...
}

django-baton changelist filters form

Javascript translations

In Baton v2 we made it easy to customize all javascript strings, useful in case you need to provide you locale translations. It’s as simple as attaching an object containing your strings to the Baton namespace:

// these are the default translations, you can just edit the one you need, or add some locales. Baton engione will always
// pick up your custom translation first, if it find them.
// you can define the object before Baton.init in the base_site template
Baton.translations = {
  unsavedChangesAlert: 'You have some unsaved changes.',
  uploading: 'Uploading...',
  filter: 'Filter',
  close: 'Close',
  save: 'Save',
  cannotCopyToClipboardMessage: 'Cannot copy to clipboard, please do it manually: Ctrl+C, Enter',
  retrieveDataError: 'There was an error retrieving the data'
}

Baton.init(JSON.parse(document.getElementById('baton-config').textContent));

Messages in toasts

With this new option you can tell Baton to show all admin messages (or just some types) in bootstrap toasts.

BATON = {
    # ...
    'MESSAGES_TOASTS': True, # True | ['success', 'warning', 'error']
    # ...
}

Setting it to True causes all messages to be displayed in toasts. Otherwise you can decide which type of messages to display this way, just set its value to an array containing the desired types (success, warning, error)

django-baton messages toasts

Conclusion

Baton 2.0.0 is a major release which brings Bootstrap 5 to the world of Django admin interfaces. It comes with some nice additions and new functionalities, a cleaner graphics and enhanced dev tools.

We like Baton’s new face a lot, we hope you’ll love it too!