Django REST API as backend and ReactJS as frontend integration - django

I'm learning ReactJS and I already have experience with Django and DRF. My aim right now is to build a rather simple web application based on a Django backend and a ReactJS frontend. (Later on, when the web app is done, I'll tackle React Native).
I've been reading tons of documentation but nothing has sorted out the question:
What is the best approach to integrate a Django backend with a ReactJS frontend?
Should I keep them separate and connect them or should I mount ReactJS inside the Django application? Which one is the best-suited approach, taking into account maintenance and further development?
Thank you very much! Any opinion/hint will be appreciated.

My approach would be make an app called frontend or anything you like in Django, then all of my React code will be placed inside that app. You will also need webpack to bundle your React code then with collectstatic command Django will collect all the static files so it could be served. You can find the tutorial here

Related

How to deploy a Django backend and Flutter frontend web app

I've been working on a web application that uses Django REST Framework and Django channels in the backend and has a Flutter frontend. It works successfully when tested locally, but my question was how would I deploy this:
What server is most appropriate for this application? (it should be free as this is just a personal project I've been testing)
Do I need to deploy the frontend and backend separately?
Are there any online resources I can refer to, to help me in this process?
Any help is appreciated :)
If you want to use it only for your personal use you could use https://www.heroku.com/free to host you backend.
You could use this guide
Yes, you should deploy them seperately.
Since in your specific case the django application is only used to hold the data, provide a REST API and sockets.

Django + Angular

i am new to the world of web development and i have a very good foundation on django for backend operations. i am also learning angular for front-end applications. so far i am quite happy writing in django for backend, but i dont like to work with the django templates. My question is, is there any way to integrate angular as the front-end portion in a django environment, keeping the django as the backend??
also while we at it, is there any good designing (UI design) courses available and where (free or paid)?
What you were doing was using Django as a backend and frontend framework. But you can use Rest Framework to build an API, keeping Django only on the backend. Once you have the API endpoints built, you can consume them with Angular or any other framework.
More info:
What is an API?
The tutorial in the official website of Django Rest Framework is a great start.

How create application backend in django and create a api so that other developers can use that as well

I just started learning Django and wanted to make an application with API (probably REST) endpoints so that other developers can use it as well (like GitHub API), and I could connect it to my react app and android app. I want my backend to be on a different server and do not want to build my react app integrated with Django backend using the REST Framework.
Can anyone just give me the general idea of what I need to do?
P.S. Sorry in advance if my question sounds silly, I am still new to backend.
Creating a Django REST API should be your first step. This is pretty simple if you already have a Django app running, and will allow your React app or Android app to connect and access data.
Authentication is a step beyond. You may want to look into implementing authentication on the server you will be hosting your back end on. You can also read through this article for some guidance on implementing auth on the DRF side.
Best of luck!
First off all you can start from this.
https://www.django-rest-framework.org/tutorial/quickstart/

Deploy Django API + React app on Heroku

I'm developing an web application with React in the front-end and Django API REST in the back-end (mostly because in the future we're gonna create a mobile app). My question is, what is the best way to deploy this web app on heroku? Using two distincts heroku's app (one for React and one for Django), or to use Docker to deploy both app's in one single heroku app? (I've read a little about Docker, but i'm not sure how I would deploy it on heroku)
Thanks and sorry for the English.
A good way is deploying to one app by bundling all your front-end with webpack for example. If you are doing server side rendering probably its better to go for two separate apps.
This tutorial talks about preparing your webpack configuration and this repo shows how to deploy webpack-django heroku app

Can Django be used to combine both webapp and moblie api?

I want to use django framework to write a web site with static/dynamic pages (I will not be using angular/react - i.e. SPA technology) but I also want the web app to serve as the backend for a mobile app.
What's the best practice here? Can Django alone be used for it?
Will I need to use Django REST framework?
If you could recommend some specific modules to keep the app as simple as possible and avoid DRY code. That'd be great.
Thanks.
You have the right pointers in your question already.
Use django-rest-framework to create a rest service, create your web app in django to consume that service, create a mobile app to consume the same rest service.
In general, once you have a rest service, you can build anything on top of it. Just consume the service from whichever platform you want to build for.
I hope that helps.