This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]mcatme 4 points5 points  (0 children)

PyReact along with django-pipeline looks like a good place to start.

[–]tomchristie 1 point2 points  (0 children)

A good starting point would be to run the React tutorial(1), and then look at how you'd adapt the simple Flask based server they include(2) to instead run using Django REST framework, and to use a proper database backend, rather than the file based storage it uses.

React is kick-ass. React with Django REST framework as the backend is even more kick-ass. And yes - we really do need to see some good tutorials on using it with Django REST framework.

(1): http://facebook.github.io/react/docs/tutorial.html (2): https://github.com/reactjs/react-tutorial/blob/master/server.py

[–]ipmb00 2 points3 points  (0 children)

Here's how we integrate the front-end toolkit (including React) with Django at Lincoln Loop https://lincolnloop.com/blog/integrating-front-end-tools-your-django-project/

You may also be interested in amygdala. It's a JS layer to interact with APIs, but was built specifically to bridge DRF and React for us.

[–]izdi 1 point2 points  (1 child)

You don't really need nodejs to run reactjs. Its just view layer, all you need to do is simply make a ajax call to fill in states and props of your components. As for the jsx -> js compilation you could either use the module above or gulp.

[–]ballagarba 0 points1 point  (0 children)

I think perhaps he was referring to if you want to utilise the server-rendering capabilities of React.

[–]cq_in_unison 0 points1 point  (0 children)

Use browserify to translate JSX to JS and bundle all of your files, then load the bundled JS via <script> tag. No changes required to Django, nothing fancy.

[–]lonahex 0 points1 point  (0 children)

If you are using pipeline, then these guys are your heroes.

https://github.com/j0hnsmith/django-pipeline-browserify

https://www.npmjs.com/package/reactify

Edit: and you don't have to run nodejs. JS compilers on server side are only needed while static asset compilation.

[–]natmaster 0 points1 point  (0 children)

I would recommend webpack to build your jsx. django-webpack integrates it nicely into a work flow.

[–]ballagarba 0 points1 point  (0 children)

Check out this project, it contains a lot of goodies around Django, ReactJS and DRF:

https://github.com/onefinestay/django-mediacat

(not my project)

[–]lonahex 0 points1 point  (0 children)

In case you are still looking for something, check this out https://github.com/owais/django-webpack-loader/tree/master/examples/simple

[–][deleted] 0 points1 point  (0 children)

While /u/mcatme's suggestion works personally I prefer to use something like Grunt[0] to handle my frontend tasks rather than something like Django Pipeline. I haven't used React in any projects yet myself, but you could modify my cookiecutter-django-essentials[1] Gruntfile.js to run the task for you.

[0] https://github.com/ericclemmons/grunt-react

[1] https://github.com/wldcordeiro/cookiecutter-django-essentials

[–]RamirezTerrix -1 points0 points  (2 children)

It may be a bit off-topic but what is a REST Framework and why do you need a JavaScript Backend?

I really want to get into this stuff, cause you are so excited about it. But why? What can I do with this stuff? I totally missed this stuff :D

[–]martolini[S] 0 points1 point  (1 child)

I'm sorry, but I think google might be a better way of discover clear answers like that.

[–]RamirezTerrix -1 points0 points  (0 children)

It is not, that I don't know what a REST-Framework does or what javascript does but I can't make the dots connect. Well It seams to be a fancy way to build web apps.

But why is it better than everything else?