Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As the sibling comment says, while I disagree with specifics this article is full of gems.

@Alex3917 What do you think of using Django-rendered templates for views that don't require significant frontend interactivity?

You seem to advocate the "everything is an SPA + Rest API" approach, which I thought was interesting.



> I was surprised that you didn't advocate for using traditional server-rendered HTML for views that don't require significant frontend interactivity/client-side state management?

I don't know that there's one best choice for how to render the front end. I generally like Angular because it's strongly opinionated, and in general, strong opinions in software leads to faster velocity and lower TCO. But I don't think that Angular is the universal best choice. I do however think having the front end powered by a REST API is 100% the right move, because it draws a line in the sand where if private data or incorrect data are getting returned then there is clearly an issue. Having a specific place (the JSON response) where you can write tests against is a huge win, one big enough that imho it outweighs every possible disadvantage of REST.


OK, that's an interesting POV.

To be honest, I was surprised that you advocated writing so many tests for each view, easily 10-20 per view.

Part of the beauty of Django's various class based interfaces is that you can be confident that if you add a validator to a model field, then it will be validated by the corresponding ModelForm in the corresponding CreateView.

But then again, you advocate against OOP in python including CBVs. If you do write all your endpoints as functions, it makes more sense you need to test it because it's easy to forget to include a line of validation or whatever it is.

FWIW I love the fact that various Django classes are like DSLs. DSLs are less powerful by construction, so less buggy. It is almost like using low-code. But I do see your point about tracking inheritance and control flow, it can be a challenge at scale.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: