6 ms·
Django: what’s new in 6.0
- giancarlostoro 11mo agoTemplate partials look good, which is one of the key reasons frameworks like React are as good and popular as they are, because you can reuse small segments of code.
- squidsoup 11mo agoReact allows for encapsulation of state in a reusable component, its more than just templating.
- renegade-otter 11mo agoReact also requires you to know the long list of do's and dont's and is littered with minefields that most average developers are not even aware of. Everyone just busts out "React" for every small thing, but few commit to actually learning this pretty complicated technology. The last two recent Cloudflare outages were because of React.
- Iwan-Zotow 11mo agoReally?
- agumonkey 11mo agoindeed the vintage templating was a logical bottleneck
- f311a 11mo agoHow is it different from include? Just less files from my perspective
- chistev 11mo agoI asked the same question
- simonw 11mo agoThe "inline partials" feature is neat, means you can use and define a partial at the same time. The way you can render just a named partial from both the render() shortcut and the include tag is nice too: https://docs.djangoproject.com/en/6.0/ref/templates/language/#template-partials https://docs.djangoproject.com/en/6.0/ref/templates/language...
- f311a 11mo agoYeah, but I was doing the same thing 10 years ago with include mixed with extends and blocks. I can just include a file inside a template or render it directly.
- agumonkey 11mo agoyou're kinda right, {% partial ... %} vs {% include ... %} is not a big difference, but my mind was vaguely thinking that "includes" have often been seen as large templates, whereas partial have been after the component era with the idea of making small blocks. (my 2 cents)
- simonw 11mo agoThey're a neat design. I started using them on my blog the other day as part of trying out Django 6: https://github.com/simonw/simonwillisonblog/blob/faec3532183e993a5d143642225de045139b23a9/templates/includes/blog_mixed_list.html#L32-L59 https://github.com/simonw/simonwillisonblog/blob/faec3532183...
- chistev 11mo agoBut you could already reuse templates in Django by including them. What am I missing?
- teagee 11mo agoCheck out the HTMX example in the blog, this helped me better understand how it could be used https://adamj.eu/tech/2025/12/03/django-whats-new-6.0/#render-partials-in-isolation https://adamj.eu/tech/2025/12/03/django-whats-new-6.0/#rende...
- The_Fox 11mo agoI'm an avid HTMX user but never did I ever think "I'm using so many includes, I wish I didn't have to use include so much." What I would like is a way to cut down the sprawl of urls and views.
- adparadox 11mo agoI do a check for `request.htmx` in my views and conditionally return a template partial as needed. This reduced my need for one-off view functions that were only returning partials for htmx. Works pretty well from my experience.
- WD-42 11mo agoPartialdef inline is the real win. Lets you define parts of a page without needing to place them in another file. Reduces the mental overhead of imagining how the inclusion will look because it’s already there. The use case is mainly driven by htmx where you will have lots of these partials and the view code renders them as individual responses.
- JodieBenitez 11mo agoIt's just syntactic sugar, making life a bit easier for HTMX users (cf. "htmx was the main motivation for this feature"). I'm using Unpoly and I just render the whole page and let Unpoly swap the content according to the target selectors, so no need for this. Not much difference in perf if you dont generate gigantic pages with heavy header/footer.
- littlecranky67 11mo agoKey benefit for reusability and composability in React is IMHO that they don't use templates at all, but everything is a function.
- globular-toast 11mo agoExactly. There are a few libraries to achieve a similar thing in Python: * https://htpy.dev/ https://htpy.dev/ * https://pypi.org/project/fast_html/ https://pypi.org/project/fast_html/ * https://fastht.ml/ https://fastht.ml/ (different to above, I think) * https://github.com/volfpeter/fasthx 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.
- Induane 11mo agoThere 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.
- globular-toast 11mo agoYeah, I agree, I find them hard to read. JSX is the best thing I've used. Elsewhere in the thread someone mentioned Cotton which seems to strike a different balance. 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?
- 11mo ago
- wahnfrieden 11mo agoThere've been a variety of open source attempts at this idea. Is this official one now the best to use, or are the others still compelling?
- JodieBenitez 11mo agohttps://django-cotton.com/ https://django-cotton.com/ is component-based. I used it a bit, it's nice if you're used to the ways of front-end frameworks, I guess.
- wahnfrieden 11mo agohttps://github.com/django-components/django-components https://github.com/django-components/django-components also looked interesting
- JodieBenitez 11mo agoWhile using Cotton my thoughts were "ok, it's kinda cool... but do I really need it ? No. Is it worth the extra dependency ? No." There is something very appeasing in just pulling Django and have all the basics covered. It's nice to have options when needed though.
- apothegm 11mo agoThe most obvious value here is for HTMX, which requires a lot of partial templates.
- pier25 11mo agoAmazing that Django didn't have this until 2025
- Hamuko 11mo agoWouldn’t Jinja2 macros count?
- sgt 11mo agoI stayed away from Jinja2 ... was under the impression it has lower performance. But I could have been wrong all these years.
- Hamuko 11mo ago>For nearly all cases, Django’s built-in template language is perfectly adequate. However, if the bottlenecks in your Django project seem to lie in the template system and you have exhausted other opportunities to remedy this, a third-party alternative may be the answer. >Jinja2 can offer performance improvements, particularly when it comes to speed. https://docs.djangoproject.com/en/6.0/topics/performance/#alternatives-to-django-s-template-language https://docs.djangoproject.com/en/6.0/topics/performance/#al...
- simonw 11mo agoIt's had includes and custom template tags for over a decade. Partials are a slightly nicer design for a subset of that pattern.
- teagee 11mo agoAny 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.
- jonatron 11mo agoI'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.
- hintoftime 11mo agoWhy is celery awful?
- tclancy 11mo agoBecause it’s a seducer. It does what you need to do and you two are happy together. So you shower more tasks on Celery and it becomes cold and non-responsive at random times. And debugging is a pain in the ass. Most places I’ve been that have it, I’ve tried to sell them on adding Flower to give better insight and everyone thinks that’s a very good idea but there isn’t time because we need to debug these inscrutable Celery issues. https://flower.readthedocs.io/en/latest/ https://flower.readthedocs.io/en/latest/
- sgt 11mo ago
- ChrisArchitect 11mo agoMore discussion: https://news.ycombinator.com/item?id=46153116 https://news.ycombinator.com/item?id=46153116
- jasoncartwright 11mo ago[flagged]
- tdfirth 11mo agoAmerican hegemony, and all that.
- firecall 11mo agoIn the US they spell it as nonze.
- lagniappe 11mo agoNo we don't.
- nophunphil 11mo agoPretty positive that was a joke/bait…
- firecall 11mo agoIt absolutely was a joke Slightly absurdist non-sensical humour I’ll admit, but none the less, a joke :-)
- nophunphil 11mo agoThe best kind :)
- nine_k 11mo agoWell, https://en.wikipedia.org/wiki/Nonce_word https://en.wikipedia.org/wiki/Nonce_word It makes me sad when a secondary meaning, which does not even overcome the main meaning in usage, becomes an obstacle for the normal use of a word. It's like seeing a rainbow as a sexualized symbol not fit for children, because it also happens to be used by LGBTQ+ community. (BTW, since you're a Brit: did people stop using the word "fag" to refer to a cigarette?)
- viiralvx 11mo agoTemplate 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!
- sgt 11mo agoIf I understood correctly, to use Tasks in production right now you need to use this as well: https://github.com/RealOrangeOne/django-tasks https://github.com/RealOrangeOne/django-tasks Is that correct?
- selcuka 11mo agoCorrect. Django 6.0 comes with a standardised API, with 2 testing backends (ImmediateBackend and DummyBackend). You need a third-party backend to store and execute tasks.
- sgt 11mo agoGood to know. So no need for Django Q2 or Celery anymore either. I guess unless one has a specific reason. Has there been discussion about adopting/embedding django-tasks into Django 6.x?
- adamchainz 11mo agodjango-tasks is the reference implementation for django.tasks, by the same author. It's up for discussion if and when the DatabaseBackend gets merged, and it seems likely to me that a Redis-based backend would be suggested at some point. It takes time and energy though!
- bigthymer 11mo agoRails renders partials https://guides.rubyonrails.org/layouts_and_rendering.html#partial-layouts https://guides.rubyonrails.org/layouts_and_rendering.html#pa...
- mentos 11mo agoGiven 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.
- tirpen 11mo agoI 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 frameworks.
- vanschelven 11mo agoThe "one way" / "batteries included" aspect of Django may also make it easier for LLMs
- boxed 11mo agoIf Python produces less hallucinations it's not because of the syntax, it's because there's so much training data.
- Genego 11mo agoWhenever I saw people complain about LLMs writing code, I never really understood why they were so adamant that it just didn’t work at all for them. The moment I did try to use LLMs outside of Django, it became clear that some frameworks are just much easier to work with LLMs than others. I immediately understood their frustrations.
- m_ke 11mo agoWhat a lot of people don’t know is that SWE-bench is over 50% Django code, so all of the top labs hyper optimize to perform well on it.
- kristianp 11mo ago
- emzo 11mo agoI love how Django just keeps slowly improving at every release. 6.0 is especially cool, including lots of really useful new features. Who said dependable tech was dull - this is the way is should be done. Well done all who contribute.
- Induane 11mo agoSame! I've been using it since pre-1.0 and love it. I am currently a few blocks away from it's birthplace. Probably the wrong time or place but I am also on the market literally as of yesterday so if anyone is looking for an experienced Django guy, I'm your man! oldspiceap@gmail.com
- renegade-otter 11mo agoDude, I used Django at 1.x - before they even had an ORM. The fact that it is adding a way to run tasks, almost a quarter of a century later, is wild to me. I am not roasting it or anything, go Django, but just an observation.
- gurraman 11mo agoI think it is refreshing. They don't half-ass things into the framework. They take the time to do it right. They let every feature fight for its life, and put their effort into LTS and minimizing number of issues and API changes related to the features they do deliver. As a developer I really appreciate this. I don't have to totally rewrite my entire application every new version because the implementation wasn't properly thought through.
- renegade-otter 11mo agoThat is indeed - rare, and one of the reasons I am wary of heavy frameworks. You buy into its code AND its legacy.
- xnorswap 11mo agoI used to have this opinion about ASP.NET then ASP.NET Core and the great churn happened. It's finally settled down again, but boy the in-between years were chaotic. Not just the Framework -> Core migration itself, but the power to make breaking changes went to their heads, and they started quickly tearing up everything only to change their minds again, such as a short-lived "project.json" syntax. Django is exactly the technology I'd pick if I wasn't already super familiar with the .NET stack. It's got the "batteries included" feel without the chaotic confusion of a million ways to do things. It doesn't have the breaking changes churn that happens elsewhere too.
- anticodon 11mo agoDjango had ORM from the very beginning. I've been using Django since 0.95 at it had ORM even back then. It was primitive but I hadn't to resort to raw SQL until much later.
- kissgyorgy 11mo agoI find templates atrocious to use for component fragments like this, that's why I wrote a Python component library when I started using Django with HTMX. Order of magnitude more pleasant to use, works with _every_ Python web framework not just Django: https://compone.kissgyorgy.me/ https://compone.kissgyorgy.me/
- aynyc 11mo agoI've been using Django on and off at work for the past few years. I really like it. That being said, I still find its ORM difficult. I understand it now that since it's an opinionated framework, I need to follow Django way of thinking. The main issue is that at work, I have multiple databases from different business units. So I constantly have to figure out a way to deal with multiple databases and their idiosyncrasies. I ended up doing a lot of hand holding by turning off managed, inspectdb and then manually delete tables I don't want to show via website or other reasons. For green webapps we have, django is as good as it gets.
- melvinroest 11mo agoMaybe this shows my data analyst tendencies, but why not use SQL?
- aynyc 11mo agoThat’s what we do now. But it gets repetitive and not leveraging Django core features.
- sgt 11mo agoAlso don't underestimate setting up e.g. views or materialized views even that you can use through the ORM to query. It helps a lot and allows you to combine fine tuning SQL with ease of use through Django, and get a lot of performance out of it. Just remember to create them in the migration scripts.
- aynyc 11mo agoAny docs? Django migration is a HUUGE pain point for us.
- WesleyJohnson 11mo agomanage.py makemigrations myapp --empty --name add_some_view (in the migration file) operations=[migrations.RunSQL("Create View some_view AS ....", "DROP VIEW IF EXISTS...."] (in your models.py) class SomeView(models.Model): class Meta: db_table = 'some_view' managed = False manage.py makemigrations myapp --name add_some_view_model
- jamesbfb 11mo agoI’m very much an Odoo guy who has dabbled with Django (and notably, celery in the past) but as someone who makes huge use of the Odoo OCA queue module[0], I never understood why Django never made use of the Postgres LISTEN/NOTIFY to offload tasks. Maybe this is my misunderstanding as I’m pretty green with the Django ecosystem as a whole. [0] https://github.com/oca/queue https://github.com/oca/queue
- manthangupta109 11mo agoI have been using Django on and off for the last 5-6 years, and it does have the advantage of having batteries loaded but it just feel heavy overall