Ustun, thanks a lot. I think I start to get it. So if I don't care about server-side rendering of React templates (which I will try avoid in the beginning stages, anyway), I can skip node.js.
Learning React is on my todo list. Then I'll need to dig deeper. I suppose then I might change my mind...;-) On Monday, January 26, 2015 at 10:14:33 AM UTC-6, Ustun Ozgur wrote: > > Hi Bob, > > On Sunday, January 25, 2015 at 5:52:00 PM UTC+2, bobhaugen wrote: >> >> Ustun, >> >> Please say more about the advantages? As in, what can you do by adding a >> node.js server to the mix (and so requiring everybody else who wants to use >> your Django project to do the same, learn and manage node.js, etc.) that >> you could not do with just plain Django on the server and React.js on the >> client? >> > > The main issue here is duplication of templates, if you use plain Django > on the server and React.js on the client. If you don't want to have any > server side rendering, that's OK for some projects, for example in the > current project I'm working on, we don't have that requirement, so Django > mainly serves as an api; we use the template system of django very > sparingly. > > Note that the amount of node.js in this project is very small, rather I > assume the programmer is familiar with both react and django. > > > >> And why you would not just want to bite the bullet and use node.js >> instead of django in the first place? >> > > > As to why django instead of node.js, that's dependent on the requirements > and age of a project. For most brown-field projects, that's not an option. > Besides that, I believe that outside templating system, remaining parts of > Django (models, managers etc) are solid, so I still prefer that as opposed > to a node.js solution. But that's clearly a personal preference. > > Ustun > > > > >> >> On Sunday, January 25, 2015 at 9:41:33 AM UTC-6, Ustun Ozgur wrote: >>> >>> >>> >>> On Sunday, January 25, 2015, bobhaugen <[email protected]> wrote: >>> >>>> Ustun, do you think it is necessary to use a node.js server to interact >>>> with react.js on the client side? Seems like a lot of added complexity. >>>> But >>>> I could be missing something important... >>>> >>> >>> Hi Bob, >>> >>> This is definitely not the only way but I don't think it adds that much >>> complexity considering the advantages. You could have multiple node.js >>> renderers, gain fault tolerance and performance via some distribution >>> scheme like round-robin. The nodejs renderer here is stateless and could >>> be made even faster through memoization or caching (or cache could be >>> handled on python side too before communicating with node) >>> >>> Another alternative would be to use something like queues to handle >>> communication between node and django, but that is more complex. >>> >>> The other alternative would be to fork a nodejs process on each call, >>> for a high traffic site, speed might be more of an issue there. Some >>> projects take that approach, I recently saw another django-react >>> integration that uses that. (See django-node for this) >>> >>> If you are on jvm, it is possible to use nashorn to do in process >>> rendering. >>> >>> Best, >>> >>> Üstün >>> >>> >>> >>> >>> >>>> >>>> >>>> On Saturday, January 24, 2015 at 7:13:56 AM UTC-6, Ustun Ozgur wrote: >>>>> >>>>> Last year I gave a conference talk at Djangocon EU where I introduced >>>>> React.js to the community. Since then, I have been getting some emails >>>>> asking for some sample code. >>>>> >>>>> I just published a sample project that simply uses a node.js server to >>>>> delegate server side rendering from Django. Hope that this is useful to >>>>> some newcomers. (Note that this sample doesn't show server side rendering >>>>> via react-router, the route on the clientside is a single one) >>>>> >>>>> I'm planning to write a blog post explaining the code if there is any >>>>> interest. >>>>> >>>>> https://github.com/ustun/django-react-integration >>>>> >>>>> >>>>> Ustun >>>>> >>>> >>> >>> >>> >>> >>> >>>> -- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "Django users" group. >>>> To unsubscribe from this topic, visit >>>> https://groups.google.com/d/topic/django-users/-7oLnG_MaGE/unsubscribe. >>>> To unsubscribe from this group and all its topics, send an email to >>>> [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at http://groups.google.com/group/django-users. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-users/b7cca6c2-2b51-4bf0-8ade-d2776e3e77b7%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/django-users/b7cca6c2-2b51-4bf0-8ade-d2776e3e77b7%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> -- >>> Ustun Ozgur >>> >>> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e0a15f3d-a1b9-4cdd-b78f-246ad772d55c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

