top | item 28877519

(no title)

bwood | 4 years ago

Seems like a strange bit of feedback to me. My company uses Django as the backend for our REST API and it's simply phenomenal. Django isn't a complete solution out of the box, but that's why things like Django REST Framework [0] exist. It supports JSON-based views and has an excellent serialization layer that can map directly to the ORM models.

This setup does NOT help with serving our frontend app, but we're using React for that anyway and I'm not sure I'd want our frontend so tightly coupled to the backend.

The fact that Django is mature and extremely stable between versions is a huge selling point for us. I'm not interested in making sweeping changes to our backend just because someone invented a new paradigm that may or may not be helpful to our app (eg, GraphQL).

That said, rendering HTML templates server-side does feel pretty archaic these days. I think it would be great for Django to take a more API-centric approach for a default installation. I can imagine that anybody coming from the JS world would feel totally out of place in terms of how Django works out of the box.

[0] https://www.django-rest-framework.org/

discuss

order

spookylukey|4 years ago

I think the case for server-side HTML rendering has never been stronger, and of all Django projects I work on, the ones I enjoy most are those that never got on the SPA bandwagon. From both a developer and user point of view I find them much faster and less painful. There are many cases where you really, really don't need the massive amount of extra complexity involved in designing APIs, adding JS frameworks etc.

When you need a bit of extra UI goodness, htmx https://htmx.org/ is a fantastic solution, and you can still use SPA-type approaches for things that need them.

You can also benefit from massively faster (and more reliable) functional testing when you are mostly standard HTML - see django-functest https://github.com/django-functest/django-functest/ for an example of this.

midrus|4 years ago

I like Unpoly[1] a lot. Seems like the perfect companion for django template based projects. It's like htmx but with more features.

https://unpoly.com/

rlawson|4 years ago

Second the recommendation for htmx. It is awesome.

mikepurvis|4 years ago

The core DNA of Django has always been conventional publishing / content management. It's usable for SPA, hybrid rendering models, and so on, but I would be nervous about putting in too much to make those first class, vs just steering people to other projects or frameworks for which those types of uses are the primary target.

zer01|4 years ago

I typically use DRF + Django for the backend and then have one “view” that renders an index.html with a context bridge (passed via a global JS variable) so I can bootstrap the front end with enough server side state to load quickly (and do feature gating and whatnot).

Seems to be a great combo to me - you get all the awesomeness of Django/DRF and none of the more archaic html temperate rendering stuff.

The only bad bit I’ve found in Django is lack of real websocket support when it’s needed. Server side events are great to have.

copperx|4 years ago

What do you mean by "real"?

sillycube|4 years ago

But the template renderer is so powerful. I can easily any print any data to the frontend. I do both Vue and Django in hybrid.