# Topic covered
* Intro to Django ORM
* General/Basic Queries
* Field lookups
* Set Operations
* F() Expression
* Aggregation
* Django Annotations
[Read More]
02-Django ORM Relationship
Django ORM Relationship
# Topic covered
* Relationship
* OneToOne
* ManyToOne
* ManyToMany
* related_name
* related_query_name
[Read More]
03-Django ORM Optimization
Django ORM Optimization
# Topic covered
* Django Tools
* Django Debug Toolbar
* django-extensions
* Django Query optimization
[Read More]
1. API and it's types
SOAP, RPC, Websocket, REST
1. API
API stands for Application Programming Interface
.
It’s a software interface that allows two or more applications to interact
with each other without any user intervention.
It offers products or services to communicate with other products and services without having to know how they’re implemented
.
Protocols that can be used in APIs are TCP, SMTP, HTTP
[Read More]2. Rest Framework
Django Rest Framework
REST API
REpresentational State Transfer
API (Application Programming Interface)
Its an architectural style
for providing standards between computer systems on the web, making it easier for systems to communicate with each other.
- It provides a
set of principles/rules
for building web services that used HTTP as a communication protocol. - An API that follows REST standard are called as
RESTful API
- GET, POST, PATCH, PUT and DELETE
3. DRF Serialization
Serializer and Model Serializer
Serialization
Serializers allow complex data such as querysets and model instances
to be converted to native Python datatypes
that can then be easily rendered into JSON,
XML or other content types.
Serializers also provide deserialization, allowing parsed data to be converted back into complex types
,
after first validating the incoming data.
4. DRF Function based View
Requests and Responses, Function based View
Request Object
REST framework introduces a Request object
that extends the regular HttpRequest, and provides more flexible request parsing.
The core functionality of the Request object is the request.data
attribute, which is similar to request.POST
, but more useful for working with Web APIs.
- request.POST
- Only handles
form data
. - Only works for
'POST' method
.
- Only handles
- request.data
- Handles arbitrary data.
- Works for ‘POST’, ‘PUT’ and ‘PATCH’ methods.
5. DRF Class-based Views
APIview, Mixins, Generic - Class Based Views
Class-based Views
Keep our code DRY
(Don’t repeat yourself).
One of the big wins of using class-based views is that it allows us to easily compose reusable bits
of behaviour.
# Types
* APIview
* Mixins
* Generic
[Read More]
6. DRF ViewSets & Routers
ViewSet, ModelViewSet, ReadOnlyModelViewSet, GenericViewSet
6.1 ViewSets
ViewSet classes are almost the same thing as View classes, except that they provide operations
such as retrieve, or update, and not method handlers
such as get or put.
In other word ViewSet class is simply a type of class-based View
, that does not provide any method handlers
such as .get() or .post(),
and instead provides operations/actions
such as .list() and .create().
7. Relationships & Hyperlinked APIs
ModelSerializer, HyperlinkedModelSerializer
ModelSerializer vs HyperlinkedModelSerializer
- ModelSerializer
- By default, Relationship will show –>
as primary keys
- By default, Relationship will show –>
- HyperlinkedModelSerializer
- By default, Relationship will show –>
as url
- By default, Relationship will show –>