0% found this document useful (0 votes)
15 views8 pages

Backend REST API With Django

Uploaded by

abhiparasharr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views8 pages

Backend REST API With Django

Uploaded by

abhiparasharr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Backend REST API with Django

App design

Backend REST API with Django 1


We are going to use python language and the Django Framework

We are also going to use Django REST framework, it is an add-on to django


and has features to build the REST API.

Postgre SQL to store the data within a database

Containerization is a software deployment process that bundles an


application's code with all the files and libraries it needs to run on any
infrastructure. We use Docker for this

Backend REST API with Django 2


Swagger

Django Project Structure


These projects are split up into various apps

Test Driven Developments


Unit Test:
These are codes that checks another code

We setup some conditions. For example: setting inputs to a function

Run a piece of code. Like running a function or calling an API

Then we check the output of the code using “Assertions”

Backend REST API with Django 3


TDD:
This is a development practice.
There can be two ways to approach this:

1. We write our functionality first and then write the unit tests for it

2. We write the tests first and then write the functionality. This is the
recommended method

TDD Process:

Backend REST API with Django 4


💡 We first write a test that checks certain functionality and then we run the
test. The test fails as we not added the functionality. Then we Add the
Feature which makes the test pass. Then we run the test again, it
passes. Then we refactor the code and run the test again and it should
pass

Project Setup

Backend REST API with Django 5


Backend REST API with Django 6
💡 Why use Docker?

1. Consistency in the local machine and the server you deploy in as you
use the same code in both using docker. So there will be no errors
that you are getting in your production and cannot reproduce in your
local machine.

2. Consistency with other devs machines.


(These inconsistencies occur between different machines are
because of the difference in dependencies version or type (like
different version of python or any database we are using)).
Docker solves this because we all run docker images when a
project is setup using docker and the dependencies are all the
same for everyone i.e stored in docker images.

1. For cleanup, just del the docker image file or where you have
installed the dependencies using docker

Docker Use:
First we will define the dockerfile, This file will contain all the operating system
level dependencies our project needs.

Then we will create Docker compose Configurations. This tells how to run the
images that are created from our Docker File configuration

We will run all the commands through docker compose

Backend REST API with Django 7


Configuring Docker Hub:
Go to Account setting —> Security and then add an access token

Access token → Used to authenticate git project with docker hub account.
This could be seen as the alternative to passwords. This token are added to
git repo, that gives it access to log into the docker hub account.
To disconnect the access, you can just delete the token

Backend REST API with Django 8

You might also like