4 ms·
REST Framework is frankly... flawed. Full of good ideas, but in practice, it leads to development hell unless you're very rigorous with it. FastAPI is the gold
by scrollaway 3y ago
REST Framework is frankly... flawed. Full of good ideas, but in practice, it leads to development hell unless you're very rigorous with it.
FastAPI is the gold standard, which in the Django works means Django-Ninja.
If you've been building individual React components and integrating them without going the SPA route, then while there are some upsides to that, you are doing a lot of the effort but not getting most of the benefits.
If you don't need an SPA, then you don't need an SPA. Nobody should be getting this development pattern shoved down their throats. But from what you describe, it sounds to me like you went with a bad approach altogether, so no kidding it created more problems.
(Not to make it sound like a "no true scotsman" with the whole "bad approach" thing, but this is why it's important to get people who really know their shit in driving refactors like these, and can make a strong plan ahead of time, detailing what value is brought at each and every step)
- globular-toast 3y agoThe lesson learnt is that React is an "all or nothing" type thing. You'll notice "SPA" isn't mentioned at all on the React website, but there's lots of mentions of building components. There are lots of comments around places like HN of people learning the same lesson as me. We never scoped replacing our entire UI with React and entire backend with JSON API because it seemed like there was a smooth upgrade path, but there isn't really. As for people who know their shit, how do you think said people learnt their shit? Everyone can do what they already know. The interesting stuff is on the frontier of your knowledge. You learn by pushing that boundary and, when you fail, thinking about why it failed.
- scrollaway 3y agoReact isn’t all or nothing… you can upgrade bit by bit, extremely incrementally. But if you’re mix and matching frameworks and paradigms together then yes expect to not get the full value. It’s like judging Django when only using it for its utils package and saying it’s “all or nothing”. Django isn’t really all or nothing either but you won’t get its full value if you just use it to supplement Wordpress for a single endpoint or something.
- robertlagrant 3y ago> because it seemed like there was a smooth upgrade path, but there isn't really You can put a React component into a non-React web page and give it data to render from however you like. Isn't that the intended path?
- globular-toast 3y agoYes, and that is indeed what we did. But what happens is you end up with a backend awkwardly fragmented into restframework viewsets and normal Django views. Often you end up having to maintain both. And then your frontend is in two distinct "worlds" which are developed in completely different ways. Unless you finally get to having an SPA and only JSON on the server side you'll feel forever in limbo. HTMX just makes so much more sense for an existing Django project unless you can afford to stop development and go all in on React, and even then only if it's really necessary to have an SPA.
- robertlagrant 3y agoYeah - agree that the Django path to add REST endpoints alongside HTML ones is not the best. I like Flask for this reason: it walks the line between HTML rendering and JSON responses really well, IMO.