Earlier quoted context omitted.
Key benefit for reusability and composability in React is IMHO that they don't use templates at all, but everything is a function.
Exactly. There are a few libraries to achieve a similar thing in Python: * https://htpy.dev/ * https://pypi.org/project/fast_html/ * https://fastht.ml/ (different to above, I think) * https://github.com/volfpeter/fasthx Probably others. I strongly prefer this to templating, but I find it makes dyed in the wool Django people squirm.
Django: what’s new in 6.0
81–90 of 127 posts
Re: Django: what’s new in 6.0
#82Earlier quoted context omitted.
Exactly. There are a few libraries to achieve a similar thing in Python: * https://htpy.dev/ * https://pypi.org/project/fast_html/ * https://fastht.ml/ (different to above, I think) * https://github.com/volfpeter/fasthx Probably others. I strongly prefer this to templating, but I find it makes dyed in the wool Django people squirm.
There are a lot of cool things about these, one that they are less typo prone and also they are often much faster. The downside is I find them hard to read. I think the template approach isn't quite right and yet neither is the functional approach. At the end of the day these are a type of tree structure; I think we could conjure a new mechanism that gets the best of most/both worlds.
To be honest my main problem with templates is they have to be one per file. In principle there's no difference between naming a new file and naming a function, but in practice it just sucks. It's a higher barrier so people are less likely to write smaller components, and refactoring support completely sucks. Even renaming a template is a massive pain whereas renaming a function with decent LSP support is easy.
JSX hits that perfect balance between readability while still being regular functions. Maybe something is possible with the new 3.13 template strings?
Re: Django: what’s new in 6.0
#83Re: Django: what’s new in 6.0
#84Earlier quoted context omitted.
Key benefit for reusability and composability in React is IMHO that they don't use templates at all, but everything is a function.
Exactly. There are a few libraries to achieve a similar thing in Python: * https://htpy.dev/ * https://pypi.org/project/fast_html/ * https://fastht.ml/ (different to above, I think) * https://github.com/volfpeter/fasthx Probably others. I strongly prefer this to templating, but I find it makes dyed in the wool Django people squirm.
A jinja/django template has an implicit context but for nested functions you really have to pass that context down through every function call.
It inevitably ends up just a big dict blob.
You get some typing support in an IDE but nothing really for function parameters.
Maybe I am doing wrong?
Re: Django: what’s new in 6.0
#85Template Partials and HTMX seems like the Django equivalent of View Components and Stimulus for Rails, which is nice. Also, good to see first class support for Tasks, among a lot of other niceties!
https://guides.rubyonrails.org/layouts_and_rendering.html#pa...
Re: Django: what’s new in 6.0
#86Earlier quoted context omitted.
Celery is great and awful at the same time. In particular, because it is many Python folks' first introduction to distributed task processing and all the things that can go wrong with it. Not to mention, debugging can be a nightmare. Some examples: - your function arguments aren't serializable - your side effects (e.g. database writes) aren't idempotent - discovering what backpressure is and that you need it - losing…
> your side effects (e.g. database writes) aren't idempotent What does idempotent mean in this context, or did you mean atomic/rollback on error? I'm confused because how could a database write be idempotent in Django? Maybe if it introduced a version on each entity and used that for crdt on writes? But that'd be a significant performance impact, as it couldn't just be a single write anymore, instead they'd have to d…
Re: Django: what’s new in 6.0
#87Earlier quoted context omitted.
Why is celery awful?
> The Many Problems with Celery: — https://steve.dignam.xyz/2023/05/20/many-problems-with-celer... > The problems with (Python’s) Celery: — https://docs.hatchet.run/blog/problems-with-celery > Dramatiq motivation: — https://dramatiq.io/motivation.html Here are some alternatives: Dramatiq: https://github.com/Bogdanp/dramatiq RQ: https://github.com/rq/rq Huey: https://github.com/coleifer/huey Hatchet: https://github.co…
https://news.ycombinator.com/item?id=45797228
https://python-absurd-client.readthedocs.io/en/latest/quicks...
Re: Django: what’s new in 6.0
#88Given that Python tends to produce fewer hallucinations when generated by LLMs I wonder if former Django developers using AI tools are secretly having a blast right now.
I think another ace up Django's sleeve is that it has had a remarkable stable API for a long time with very few breaking changes, so almost all blogposts about Django that the LLM has gobbled up will still be mostly correct whether they are a year or a decade old. I get remarkably good and correct LLM output for Django projects compared to what I get in project with more fast moving and frequently API breaking framew…
Re: Django: what’s new in 6.0
#89Earlier quoted context omitted.
> your side effects (e.g. database writes) aren't idempotent What does idempotent mean in this context, or did you mean atomic/rollback on error? I'm confused because how could a database write be idempotent in Django? Maybe if it introduced a version on each entity and used that for crdt on writes? But that'd be a significant performance impact, as it couldn't just be a single write anymore, instead they'd have to d…
In the context of background jobs idempotent means that if your job gets run for a second time (and it will get run for a second time at some point, they all do at-least-once delivery) there aren't any unfortunate side effects to that. Often that's just a case of checking if the relevant database updates have already been done, maybe not firing a push notification in cases of a repeated job.
Re: Django: what’s new in 6.0
#90Any code or blog written by Adam is worth spending some time on. It will be interesting to see how the tasks framework develops and expands. I am sad to see the great Django-Q2 lumped in with the awful Celery though.
I'm of the opinion that django task apps should only support a single backend. For example, django-rq for redis only. There's too many differences in backends to make a good app that can handle multiple. That said, I've only used celery in production before, and I'm willing to change my mind.