Django Server Part 2 + Angular 6 example | Django Rest Framework + MySQL CRUD example

Django Server Part 2 + Angular 6 example | Django Rest Framework + MySQL CRUD example

Django server to do CRUD with MySQL (including finder method) - Django post/put/get/delete to MySQL database example- Django restApi server example

https://ozenero.com/django-angular-6-example-django-rest-framework-mysql-crud-example-part-2-django-server

Django + Angular 6 example | Django Rest Framework + MySQL CRUD example – Part 2: Django Server

This tutorial is part 2 of Django-Angular-MySQL series. Today, we will create Django server to do CRUD with MySQL (including finder method).

>> Part 1: Overview >> Part 3: Angular Client

Related Post:

Video

Django RestApi server Overview

Goal

Our Django Server can work with MySQL Database and provides APIs:
  • GET /customers/: get all customers
  • GET /customers/[id]: get a customer by id
  • GET /customers/age/[age]: find all customers by age
  • POST /customers/: save a customer
  • PUT /customers/[id]: update a customer by id
  • DELETE /customers/[id]: delete a customer by id
  • DELETE /customers/: delete all customers

Architecture

django-angular-6-django-rest-api-mysql-angular-server-architecture

Project structure

There are several folders and files in our Django project: django-angular-6-django-rest-api-mysql-angular-django-project-structure
  • customers/apps.py: declares CustomersConfig class (subclass of the django.apps.AppConfig) that represents our Django app and its configuration.
  • gkzRestApi/settings.py: configures settings for the Django project, including INSTALLED_APPS list with Django REST framework and Customers Application.
  • customers/models.py: defines Customer data model class (subclass of the django.db.models.Model).
  • migrations/0001_initial.py: is generated by makemigrations command, includes the code to create the Customer model, will be run by migrate to generate MySQL database table for Customer model.
  • customers/serializers.py: declares CustomerSerializer class (subclass of rest_framework.serializers.ModelSerializer) for Customer instances to manage serialization to JSON and deserialization from JSON.
  • customers/views.py: contains methods to process HTTP requests and produce HTTP responses (using CustomerSerializer).
  • customers/urls.py: defines urlpatterns to be matched with request functions in the views.py.
  • gkzRestApi/urls.py: defines root URL configurations that includes the URL patterns declared in customers/urls.py.

    Setup Django RestApi project

    Install Django REST framework

    Django REST framework works on top of Django and helps us to build RESTful Web Services flexibly. To install this package, run command: pip install djangorestframework

    Create RestApi project

    Create Django project named gkzRestApi with command:

More at:

https://ozenero.com/django-angular-6-example-django-rest-framework-mysql-crud-example-part-2-django-server

Django + Angular 6 example | Django Rest Framework + MySQL CRUD example – Part 2: Django Server

django angular mysql crud

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Django Angular 10 CRUD Example - MySQL + Django Rest Framework Tutorial

I introduce how to implement Django Angular 10 CRUD Example - Fullstack: Angular 10 + Django Rest Framework + MySQL Tutorial

Django Angular 10 CRUD Example - MySQL + Django Rest Framework Tutorial

I introduce how to implement Django Angular 10 CRUD Example - Fullstack: Angular 10 + Django Rest Framework + MySQL Tutorial

Django + Angular 6 example | Django Rest Framework + MySQL CRUD example

How to create Angular Client to make HTTP request & receive response from Django Server - Angular 6 Django MySQL example - Angular Rest Client Django server

Django Angular 8 MySQL CRUD Example - using Django Rest Framework

In the tutorial, I introduce how to build "Django Angular 8 MySQL CRUD Example - using Django Rest Framework" with clearly coding example

Django + Angular + MySQL example: CRUD App | Rest Framework

Step by step to build Django + Angular + MySQL example CRUD app using Django Rest Framework for Rest APIs, MySQL, Angular 11/10/8