2021-06-07 PEP 661 + htmx/PostgREST + django-htmx ¶
PEP 661 – Sentinel Values ¶
htmx ¶
PostgREST ¶
i’ve had a hypothesis for a while that an htmx extension can be taught to speak PostgREST/pREST and then have a nice way to both do CMS and automake pages
About PostgREST: The umbrella term is « Backend for frontend » (like GraphQL). HTMX is different. HTMX brings HTML to the frontend. Creating the HTML is the job of the backend. How you do this in the backend (with PostgREST/GraphQL or direct SQL) is up to you and not related to htmx.
Does this answer your question?
I understand the intent - if PostgREST generated HTML directly then that would be great. To avoid additional server/intermediate components an HTMX extension could perform this itself. I’ve done this for specific cases and the simplicity it provides is excellent.
postgREST is basically a wrapper around your database that automatically creates a JSON REST API
Perhaps I’m saying this poorly. Firstly, I’ve done this in limited contexts and a JSON/HTML conversion done in an HTMX extension allowed direct usage of PostgREST that worked well.
This is just a report that this combination of tech along with HTMX was a pleasure to work with.
Second, agreed that this is out-of-scope as a core HTMX concern.
But as an extension it is simpler to test/implement/iterate than on modifying the backend.
Two years ago I thought GraphQL will be the future. But my mind changed. GraphQL and other Backend-for-frontend tools are not the tools I want to work with. I prefer to create html with Python+Django+PostgreSQL. But that’s only my personal opinion
- @fielding
-
was pretty specific folks:
« The REST interface is designed to be efficient for large-grain hypermedia data transfer, optimizing for the common case of the Web, but resulting in an interface that is not optimal for other forms of… interaction »
Django_htmx 1.1.0 (2021-06-03) ¶
-
https://github.com/adamchainz/django-htmx/blob/main/HISTORY.rst#110-2021-06-03
-
Support the HX-History-Restore-Request header, which was added in htmx 1.2.0. This is parsed into the request.htmx.history_restore_request attribute.
-
Support the Triggering-Event header, which is sent by the event-header extension. This is parsed into the request.htmx.triggering_event attribute.
-
Stop distributing tests to reduce package size. Tests are not intended to be run outside of the tox setup in the repository. Repackagers can use GitHub’s tarballs per tag.