I have received a lot of statements that developers are moving to React instead of using Django. I am new to full stack development. And I am currently using Django as my framework. Wanted to get some feedback from the community should I continue with Django or start looking at React? Thanks in advance.
Hey @chosen1!
You can integrate React with Django so you don't have to choose between the two. React is a frontend library, while Django will take care of your backend (authenticating users, storing stuff in the database etc.).
In order to use the two together you have to build an API - I suggest using the Django Rest Framework for this. I have recently started playing around with React on Django and while I found it a bit difficult to set up at first, it is actually an enjoyable stack.
@phkundi Thanks for your response this is definitely helpful.
You can use both. The only difference is that instead of using templates on the Django side for responding to requests, you would just use it to serve up a REST API. This would let you keep all the benefits of the admin scaffolding that Django provides. You can then use React to create a single page app on the client side.
FWIW I've been having great luck with writing React apps in Python using the Transcrypt transpiler with Parcel to generate the javascript bundle. It has allowed me to stay in Python land 95% of the time and avoid having to switch my brain into javascript mode.
@JennaSys wow this is very helpful. I have a simple application I am trying to create as my first official app I bring to market. But afterwards I will look at learning React.
The notion of Django versus React (i.e., the idea that they're mutually exclusive) is nonsense.
My company (Pinecast) is built on Django and uses a TypeScript+React front-end (https://github.com/Pinecast/pinecast-ts). I use Graphene and Graphene-Django, and Apollo for typed communication between the front-end and back-end. My work-in-progress side project is running on the same stack, but keeps the front-end and back-end in the same repo (rather than having a front-end monorepo). I am preferring the single repo approach, but across both projects I haven't had ANY issues with Django getting in the way.
In my WIP project, I even use Django Channels to establish GraphQL subscriptions over websockets. It's really quite good.
If anything, the combination of the two is more powerful than each tool on its own. Django gives you a really well-typed ORM for free with a built-in admin tool. React, TypeScript, and Apollo give you typed front-end code that updates when you change your schema. I honestly wouldn't trade this workflow for any purely-JS alternative in a million years.
Thanks for your feedback!
Hi,
Personal opinion here. I don’t think you need to decide either or. Django is pretty good at creating an application from routing to dB access and quick UI. React is awesome when it comes to dynamic web content. Use django and drop in react everywhere u need dynamic content. I love both and try to get the most out of them. There is no right or wrong answer here I believe.
To also comment on the other posts here sure you can make a cut and use django just as an API but you also can mix django UI and just mount react components to dom elements when needed.
@hmontazeri Thanks for your input
Do whatever gives you speed.
If you're doing django, Heroku is playing really nice, so you can deploy your apps very easy
@brunor thank you
Yeah huge learning curve but I recommend using
Django
Django Rest Framework
Hasura
Graphql
React (nextjs for public facing projects or create react app for private think SaaS)
After a ton of researching that seems to be the way forward.
@volkandkaya thanks for the clear direction. This has helped a lot!
No problem.
I believe having someone opinionated saves you a ton of time and doubt :)
@volkandkaya I agree. how many years of experience do you have in coding with Django? Just curious
4 years.
Been doing frontend with React mostly recently.