Skip to content

Angular Django CRUD RestAPIs Application Examples Fullstack Angular 10 Django MySQL PostgreSQL Tutorial

loizenai edited this page Jul 21, 2020 · 1 revision

Angular Django CRUD App

All Details the Tutorial and cleary coding, visit at: https://loizenai.com/angular-django-crud-restapis-application-examples-fullstack-angular-10-django-mysql-postgresql

Django is a Python-based free and open-source web framework that follows the model-template-view architectural pattern. Angular is a TypeScript-based open-source web application framework led by the Angular Team at Google. In the tutorial, I introduce how to build a Angular Django CRUD RestAPIs Fullstack Project with POST/GET/PUT/DELETE requests with step by step coding examples.

Architecture – Angular Django CRUD Application

Overall Architecture – Angular Django RestAPIs FullStack Integration

  • We build the backend Python Django Application that provides RestAPIs for POST/GET/PUT/DELETE Customer entities and store them in MySQL/PostgreSQL database.
  • We implement the Angular CRUD Application that uses Angular HTTPClient to interact (call/receive requests) with Django backend’s RestAPIs and display corresponding page views in Browser

DJANGO APPLICATION

Django RestAPIs Workflow

Django Application interacts with MySQL/PostgreSQL database via Model layers. The Views are simply Python functions that take web requests and return web responses. URLs are used to mapping each request with the corresponding views.

Django RestAPIs Workflow Architecture

Django Project Structure

Django Project Structure

  • djangoLoiZenAiRestAPIs is a main project folder
  • customers is an application folder

ANGULAR APPLICATION

Angular Frontend Architecture

Angular Application Architecture

Angular CRUD Application is designed with 3 main layers:

  • Service Layer is used to define Angular Common Services and HttpClient Services to interact with RestAPIs
  • Component Layer is used to define Angular Components to show views in Browser for interacting with Users
  • Router Layer is used to route URLs mapping with the corresponding Angular Components

Angular Project Structure

Angular Project Structure

Angular CRUD Application defines 3 components, 2 services, 1 routers, and 2 data models:

– Components:

  • add-customer component is used to add a new customer to system

  • list-customer component is used to show all customers on view pages, delete a customer and update a customer

  • message component is used to define a view to show logging message on browser – Services:

  • customer.service.ts defines POST/GET/PUT/DELETE HTTP requests to Django RestAPIs with the built-in Angular HttpClient.

  • message.service.ts defines an array storage to log all messages when Angular CRUD App running – Router: app-routing.module.ts defines how to map a corresponding Angular component with an URL.

– Models:

  • customer.ts defines the main data model of our application.
  • message.ts defines the response data model between Django RestAPIs and Angular application.

Goal

– Add a Customer Entities from Angular Client:

Goal 1 – Add a Customer Entity

– List All Customer’s entities:

Goal 2 – List All Customer’s entities from Angular Client

– Details a Customer:

Goal 3 – Angular shows details of a Customer entity

All Details the Tutorial and cleary coding, visit at: https://loizenai.com/angular-django-crud-restapis-application-examples-fullstack-angular-10-django-mysql-postgresql

Sourcecode: