Leveraging the power of Django REST Framework's renderers with HTMX.
- 30 minutes
HTMX has been quite popular lately in the Django circles and has demonstrated how powerful it can be with vanilla Django. But... have you thought about HTMX paired with Django REST Framework and more specifically paired with DRF's flexible renderer system?
Django is most known for its admin. Ironically it is also one of the less Django-like parts of Django and one with many dimensions that make it harder to extend and fully customize. That's probably why, for several years, people have been trying to find alternatives to Django admin, packages that have had variables amounts of success like Django Grappelli, Django Admin2 or Django Admin Bootstrap.
One of these attempts is actually part of a very popular Django package, it's the Admin Renderer from Django REST Framework. Although it is quite powerful, I'm not sure it really ever caught on in the Django community.
But the Admin renderer is not the only renderer packaged with DRF, most of us are likely familiar with the Browsable API renderer and some of us have probably heard of the Template HTML renderer.
Before diving into the renderer itself, we will do a quick round-up of the capabilities DRF offers, both out-of-the box and also with a few extra addons and compare that to what Django Admin offers.
Finally we will look at the mechanics of DRF renderers and how, coupled with HTMX, the Template HTML renderer can bring dynamicity to an admin-like, feature-rich, CRUD interface born of Django REST Framework.
It will be up to you to decide... Is Django REST Framework going to be the basis of the admin of your next Django project???