[Django]-How to implement Angular with Django

4πŸ‘

βœ…

Yes, you will be using Django for REST API views. Forget about templates and Django forms, you will be just sending and receiving JSONs.

If you want to host it together you will be probably serving just index.htm. The tricky part is that you need match all possible app routes to index too (the whole Angular lives there, handling routing on client side. But initial request after reload still can lead to arbitrary url)

More common way is using two separate containers, one for api and one for angular app. Then you can provide server side rendering on angular app (this will be still calling api from it) and separate api without need to handle index.

πŸ‘€farincz

9πŸ‘

Yes, creating API’s using Django/DRF is sufficient to communicate with an Angular app.

Below is an illustration of a basic architecture of a Django Angular application.

Architecture of Django/Angular app

API endpoints in Django will be served via the urls.py files using the DRF (Django Rest Framework. The angular client will send HTTP requests using the Http Client Module and display the retrieved data on the components/pages. A data service created in Angular will use the HTTP client to send and get data. Angular Router will handle navigations to pages and components.

πŸ‘€GlenH

Leave a comment