Bringing together django, django rest framework, and htmx

Overview

This is Just an Idea

There is no code, this README just represents an idea for a minimal library that, as of now, does not exist.

django-htmx-rest

A library for bringing together Django, the Django REST Framework, and htmx.

htmx is a new javascript library that allows you to access modern browser features directly from HTML, rather than using javascript. See their docs to learn more, it is really awesome!

After learning about htmx, it is natural to realize how htmx can bring Roy Fielding's idea of REST and HATEOS to life in a new, intuitive, and powerful way. Although htmx is a frontend library, it implies a fresh look at the old paradigm for building backend-driven web applications.

Despite all of this being very exciting, sticking htmx into a Django project, or a Django project with DRF does involve a bit of friction. There are a lack of design patterns, best practices, and library support. Of course, we can build vies that "do it all," in the sense of serving JSON alongside htmx-cooperative html snippets, but doing so with consistency, repeatability, and scalability is where this library fits in.

Features

Django and DRF are already tools we know and love. This library aims to smoothly bring htmx into the mix with a minimal framework and utilities that are both easy to use and understand.

HTMX REST Views

We provide thin wrappers around DRF view classes and view function decorators which allow you to provide an html partial template. When a request comes from htmx, the template provided will be used to provide a html snippet for htmx.

Otherwise, the view will behave like a DRF view, able to serve up JSON, XML, et cetera.

New Spin on the Browsable API

With htmx, your browsable API is not just a view into your application data, but also a sort of storybook for UI components, as expressed by HTMX partials.

If you directly visit a htmx-rest view in your browser, you will still be able to access the DRF browsable API, but you'll also be able to see and interact with the HTMX component in isolation with live reloading, and basic UI development tools, like changing the viewport size, and viewing the context data being passed into the template

Also, to help you browse through all your htmx-rest views, our browsable interface has a sidebar listing all of the htmx-rest views in your application, so you can explore them.

Supercharged Content Negotiation

Content negotiation and renders are an awesome part of DRF. This library extends that functionality to provide the tools needed for supporting htmx as well. A request from htmx directly serves up the html snippet, with the serialized data being passed into your partial template. A direct browser request shows the browsable API / component explorer, and other content types are handled by DRF as expected.

You might also like...
Drf-stripe-subscription - An out-of-box Django REST framework solution for payment and subscription management using Stripe

Drf-stripe-subscription - An out-of-box Django REST framework solution for payment and subscription management using Stripe

Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App 💛 We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

Packs a bunch of smaller CSS files together from 1 folder.

Packs a bunch of smaller CSS files together from 1 folder.

PEP-484 stubs for django-rest-framework

pep484 stubs for Django REST framework Mypy stubs for DRF 3.12.x. Supports Python 3.6, 3.7, 3.8 and 3.9. Installation pip install djangorestframework-

Forgot password functionality build in Python / Django Rest Framework

Password Recover Recover password functionality with e-mail sender usign Django Email Backend How to start project. Create a folder in your machine Cr

Django Rest Framework + React application.
Django Rest Framework + React application.

Django Rest Framework + React application.

This is a basic Todo Application API using Django Rest Framework
This is a basic Todo Application API using Django Rest Framework

Todo Application This is a basic Todo Application API using Django Rest Framework. Todo Section - User can View his previously added todo items, creat

django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing
django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing

django-dashing django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project.

REST API with Django and SQLite3
REST API with Django and SQLite3

REST API with Django and SQLite3

Owner
Jack DeVries
Jack DeVries
Realworld - Realworld using Django and HTMX

Realworld - Realworld using Django and HTMX

Dan Jacob 53 Jan 5, 2023
Django datatables with htmx.

Django datatables with htmx.

Regis Santos 7 Oct 23, 2022
A music recommendation REST API which makes a machine learning algorithm work with the Django REST Framework

music-recommender-rest-api A music recommendation REST API which makes a machine learning algorithm work with the Django REST Framework How it works T

The Reaper 1 Sep 28, 2021
Atualizando o projeto APIs REST Django REST 2.0

APIs REST Django REST 3.0-KevinSoffa Atualização do projeto APIs REST Django REST 2.0-Kevin Soffa Melhorando e adicionando funcionalidades O que já fo

Kevin Soffa 2 Dec 13, 2022
APIs for a Chat app. Written with Django Rest framework and Django channels.

ChatAPI APIs for a Chat app. Written with Django Rest framework and Django channels. The documentation for the http end points can be found here This

Victor Aderibigbe 18 Sep 9, 2022
RestApi With Django 3.2 And Django Rest Framework

RestApi-With-Django-3.2-And-Django-Rest-Framework Description This repository is a Software of Development with Python. Virtual Using pipenv, virtuale

Daniel Arturo Alejo Alvarez 6 Aug 2, 2022
A starter template for building a backend with Django and django-rest-framework using docker with PostgreSQL as the primary DB.

Django-Rest-Template! This is a basic starter template for a backend project with Django as the server and PostgreSQL as the database. About the templ

Akshat Sharma 11 Dec 6, 2022
DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

Mokrani Yacine 2 Sep 28, 2022
Django API without Django REST framework.

Django API without DRF This is a API project made with Django, and without Django REST framework. This project was done with: Python 3.9.8 Django 3.2.

Regis Santos 3 Jan 19, 2022
📊📈 Serves up Pandas dataframes via the Django REST Framework for use in client-side (i.e. d3.js) visualizations and offline analysis (e.g. Excel)

Django REST Pandas Django REST Framework + pandas = A Model-driven Visualization API Django REST Pandas (DRP) provides a simple way to generate and se

wq framework 1.2k Jan 1, 2023