DJANGO 2022

 * to use django drf  first step is in setttins.py - installed app- rest_framework

* request is responsible for getting data and response is responsible for sending data

* We will use status code , if our request get ok or not  like status .https_201_created for ok and 

status.https_404_bad_request if not ok, from rest_framework import status

* @api_view is a decorator and used in function based view where as ApiView is used in class based views

* we can say that the above line are marker ki ye function API ko handle krta hai, ye class API ko handle krti hai, and we can also set there ki ye sir DELETE request leta hai, ye function sirf POST request leta hai.

* Instead of using API view if we use mixin, then our number of lines of code will reduced

* First we have to configure paginations in settings.py file 

* this inbuilt pagination work for generic and view sets

* We can do pagination at settings.py level - isse bhi kaam ho jata hai

as well as we can do pagination at class level

* pip install django-filter [ for filtering in django rest framework]

* django_filter in installed app

* In search filter we can also add many customization like how to search and all...

* We can also do ordering here

* so three things are there first is filter , Search and ordering

* Django rest framework interface is to test for CRUD operations , if you want to test custom function operation you have to use POst man

* DRF automatically validate the data depending upon how you se the rules in models.py

* WE can make custom validator to validate data before saving it to the database

* first way of doing is it do in serializers.py [ watch video in case you have prblm]

* IN earlier section we see basic authentication and now we see token based authentication system

* To enable token based authentication, you first need to add rest_framework.authtoken in settings.py installed app

* Token authentication system is good, mtlb ab theek hi hai, dekh lo

* SOME THING ABOUT ANGULAR


Comments

Popular posts from this blog

REACT NATIVE STYLE TRICKS

Tips for Django

chat model