Deploy angular 8 and django rest framework - django

I have successfully deployed django rest framework backend and angular 8 frontend apps independently on Heroku. I'm clueless whether they should be deployed as separate apps or should be integrated on single instance. What is the best practice when it comes to DRF and SPA,particularly angular? If to be deployed as independent app,how can I configure DRF backend to respond to the frontend in another server. Any help would be appreciated. Thanks

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 REST API as backend and ReactJS as frontend integration

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

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

Angular with Django development

I've almost finished developing my frontend in Angular 2 using static json files as API mocks. Now I want to use it with my real API from Django, and I'm struggling with few issues, since it is my first Angular 2 frontend.
I've moved whole Angular project generated by Angular CLI as frontend directory within my Django project. Django is exposing API at /api, and I want to perform request to that API from Angular. In production, Angular sources will be transpiled into javascript and moved into static (i guess), but I don't know how to handle it during development.
Is it possible to run Django development server with Angular ng serve on the same port at the same time? If I'll run them at different ports, I will need to hardcode my API url in frontend, and enable CORS which won't be enabled in production.
What are the best practices to develop Angular with Django?

Django Rest Framework and Angular App on same AWS Instance

I'm using Django Rest Framework for API service and Angular to use those APIs. How do I run Angular alongside Django Rest Framework on the EC2 instance using Amazon Elastic Beanstalk?
For example, Django Rest Framework serves up the API through http://test.com/api/v1/ and Angular makes HTTP requests to those API endpoints client-side.
What are the steps required to run Django Rest Framework API with an angular client side application on the same machine?
Any suggestions would be greatly appreciated!
It seems you are looking for a customized container that runs both a Python web app and an Angular app. The angular app accesses the django REST API on "localhost". I would recommend looking into creating a custom Docker container that lets you have this custom configuration.
You can read more on support of Docker containers on Elastic Beanstalk here.
While there may be simpler solutions out there I have been able to configure AngularJS + Django REST Framework to run on the same AWS instance. It's the accepted answer to this post https://stackoverflow.com/a/22852451/1759504
There I go into detail on exactly what I had to do to make it so my static AngularJS content runs from http://test.com/#/ while my APIs are at http://test.com/api/v1/