Hacker News new | ask | show | jobs
by colbyhub 1674 days ago
Another one to consider is https://www.django-unicorn.com if you want that LiveView feeling for Django.

For my latest project[1], I've opted for https://unpoly.com instead of Alipine+htmx as Unpoly allows me to write 100% server-side code and sprinkle some progressive enhancement where desirable. As a result, I can offer a no-JS experience (minus the Stripe Checkout) for those who may want/need it. Additionally, it forces me to focus solely on the server-side, and I write more idiomatic Django code as a result.

[1]: https://heraldsms.com

2 comments

https://www.django-unicorn.com/examples/count-characters

Sending an AJAX request every time you enter characters just to count them. Ewwww.

Howdy, creator of django-unicorn here. Some of the UI-specific examples are a little contrived and wouldn't be what I consider a really great idea, but it's more to show the possibilities, i.e. instead of counting characters, you could do a heavy ML task to analyze the text.

Personally, I mostly use Unicorn as a component library to split up functionality from the view code, and as a way to persist data to the backend (which would already be an AJAX call) without the hassle of creating an API, dealing with serializers, etc.

I guess that's the extreme end of no-js. Wanting to use compute, but philosophically sticking-to-your-guns on where that compute happens.
Well it's still using JS to send the AJAX request, so in-fact something along the lines of 'on text change, set some element text to text.length' is a lot less JavaScript code than 'on text change, format and POST an AJAX request and then set the element text to a value within the response'.
The difference being that the code to send an Ajax request an update the DOM based on the response is already coded and already used in other places, whereas updating the text length client-side would have to be custom code. Not that I'm arguing one way or another, but the reason it's done that way is to reuse the same set of primitives for everything.
I've been looking at these libraries and Unpoly looks the most promising for my needs. HTMX looks good as well but Unpoly's infinite layers feature [1] rather grabbed my attention :)

Stimulus is the one I can't get myself to like. Separate JS controllers is clever but the DSL and general nature - it just doesn't click with me.

[1] https://unpoly.com/up.layer