I know it was possible to do SPAs with django-rest or something, but I'm curious if Django has mostly stayed in this "older" paradigm or if its more .. modernized at this point?
I know it was possible to do SPAs with django-rest or something, but I'm curious if Django has mostly stayed in this "older" paradigm or if its more .. modernized at this point?
My experience from lessons learned over the past ten years is that SPAs generally take longer to build, are usually slower to load, have much worse accessibility and are more expensive to debug and maintain.
For a great deal of web projects you're better off with the "old paradigm".
That said... I do think there's an argument to be made that Django should include core framework features that make working with SPAs easier, rather than farming that out entirely to Django REST Framework.
Django 4.2 does have one nod in that direction: https://docs.djangoproject.com/en/4.2/releases/4.2/#django-c... - "ManifestStaticFilesStorage now has experimental support for replacing paths to JavaScript modules in import and export statements with their hashed counterparts".
Django releases a new version every six months. Packages that aren't part of Django core are free to release on a different schedule, which really helps when you're trying to innovate on something new.
In DRF's case it's now mature and stable enough that maybe that wouldn't be so much of a problem... but it's still not clear to me that having it in Django core would be a net benefit (aside from as a marketing thing) than having it live independently as it does today.
DRF’s validators don’t implement `__eq__`, Serializers doesn’t implement `serializer._meta.fields` on the base class (you have to instantiate the serializer to access anything other than `declared_fields`), lack of async view support, and on and on.
I find DRF grating and would pay anything to have an official Django REST api contrib package.
Just don't try to pretend it's a "good for everything" tool.
(I know this is not HTML per se, but it's by far my biggest pet peeve with SPA since forever, so I had to mention it.)
https://www.django-unicorn.com/
That and HTMX + Alpine.js are a strong combination.
(I also had a bash at building a similar tool for Django called Tetra but unfortunately haven't had the time needed to commit to it: https://www.tetraframework.com)
1/ "older" paradigm is still extremely useful in many cases
2/ we also use Django as a backend for SPAs. Here with Vuetify
3/ using the HTMX paradigm, you're both doing SPA and "older paradim of submitting forms"I've been trying those alternative libraries from time to time and there is always the thought "I wish I started this in Django" when project becomes more complex than a basic endpoint.
Btw I was looking into Django recently, they are still using the “older” paradigm you are referring to.
If you're twitter or facebook, or have enough domain reputation already that your crawl budget is big enough to offset, then it doesn't matter. If you are not already a big deal, then it takes a lot of off-site traction to overcome.
Practically speaking, for two otherwise-even sites just starting out, a statically rendered site has a pretty significant SEO advantage over a JS-only site.
Then the SEO penalty is just the increased page size (maybe some extra loading time). But at least the content can be crawled normally.
Subscriptions are still a bit thorny, but have come a long way now that ASGI and channels are a focus for the Django team.