Hacker News new | ask | show | jobs
by nsomaru 3524 days ago
is there a better way to get server side rendering rather than a whole dependency on node for a django project?
2 comments

If your project is small enough you can scrape it and generate all pages. You need a server only in development but then you can host it statically (and for free, e.g. on github).

Check out hasgluten.com for an example, code here (pretty old version of react though): https://github.com/hasgluten/hasgluten

That's useful, thanks.

The case I was interested in is where you'd like to have Django server-side-render the first request based on url, and then have react handle the rest via react-router and apis ala django-rest-framework.

As a backend dev who got by with jquery soup and 0 frontend build tools before (use django bundling tools), even starting to approach the React ecosystem is a little daunting.

I was where you were at a few years ago, and I really don't think these type of large SPAs are appropriate for the vast majority of business / crud sites (i.e. not Google Maps, Facebook, etc.)

I work in Java / Scala world, but have been pulled into more front-end / UI work the last few years. It seems a lot of (younger) developers use the backend only as a Restful bridge to the DB.

After seeing what is Node, Angular npm, bower, grunt, etc. and now React and friends, I'm pushing my team back to the server for all business logic and using the front-end only for dynamic forms, animations, etc.

The JS tooling is just not as good as static backend frameworks, nor are the libraries. Trying to debug dozens of async calls using Chrome Dev Tools takes 10x as long as doing it on the backend, even with multiple threads.

Doesn't avoid the node dependency, but try https://github.com/airbnb/hypernova

Honestly the node dep isn't so bad. Just think of it as a template render running on another process.

On a $5/mo 512mb/20gb DO VPS, a single django application deployed with nginx, gunicorn, postgres and redis on the same box started to OOM me (nothing in application logs!) when doing something like generating a thumbnail.

Deployed some swap and once thumbnail caches are warm we're fine, but, adding node as an additional dependency just seems overkill. python-react seems like a good fit.[0]

[0] https://github.com/markfinger/python-react

edit: s/React-python/python-react/g