Django & React Tutorial For Beginners #3 : Configure CORS Headers And Django REST Framework

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys and welcome back to another video this is the continuation video of our django react series and in this video we'll be looking into installing and configuring the course headers uh library and the django rest framework so giving you a brief on the previous video in the previous video we have looked into installing the django project creating a super admin of our admin panel uh using the migration commands to migrate our migrate things in our app and uh basic uh look around of the django boilerplate app itself so moving on uh forward with our series uh in this video we'll be performing uh installation and setting up the course policies for our app and uh installing and config in the django rest framework so this is uh what you're looking over here so this is the framework which we are going to install and this is the course headers uh library so coming on to installation of this both dependencies so first of all you can copy this from the clipboard itself copy the command and uh if you navigate to your vs code so this is basically our folder structure which you are maintaining and from this video onwards i'll be uh providing you the code also so for you guys to be in sync if you have missed anything in this video series so this is of this is the same exact folder structure from our previous video so there is nothing new in it all the basic files and folders within that so navigate to your terminal make sure you are within your backend main folder now you can just paste the command which you have copied that is pip install django course header for guys with running running on linux maybe you can use this pic3 install django core setters i've already done this so let's move ahead the second thing you need to install is the django rest framework so you can just copy this and install this same for the linux if you have a linux system please do perform a pip 3 install if you have a python 2 version so yeah this is also done from my end so i'll just walk you through the settings and configuration of it so whatever i'm performing in this uh video that is the uh adding few lines of configurable variables is covered from the documentation of itself so let me just walk you through that so adding this value to the install apps the middleware section the cause allowed origins uh variable and few other things are taken from the documentation itself so if you want to carry out that way it's fine but uh it's a part of the process for me to cover this so yeah this is also crucial same for the django rest framework installing things in the app let me just yeah so everything is taken from the documentation everything so this configuration a few inside if you dig into this you will get it but i'll make sure you don't have to do that and you can just copy everything from my settings or clone the repo which i'm going to provide you and get able to start with that yeah so everything which i'm performing in this video is coming through the documentation itself so moving on to this uh code section after installation of both these libraries using pip command navigate to my backend folder and the main settings dot pi so this is our main settings uh file which will have all the configuration regarding our rest framework so the first thing you need to add is this allowed all host so this will basically allow all the requests in your front end uh without any uh exception so it is just like a uh not mandatory thing but if you put this in your settings it will be good uh there won't be an issue the second thing is adding these three lines so this is for the odd token which will be generating which will generate our token and this is the course headers uh app so these are the three lines which will be adding after installing both these libraries so first is you will add this then within the installed apps add these three lines the more detail part of this will be coming in the further videos for right now just to install this the next thing you which will be doing is the middleware section so within the middleware section add these two lines and the next thing which is let's navigate to the bottom adding this uh part of code which is the rest framework so this is all coming from the documentation itself as i've shown you over here but there are few more things which i've added so yeah which is the basic authentication session token and token authentication so this is something which i've added along with the permissions or this one this specific thing from this part and uh yeah this is that itself the last thing you need to do is copy this uh course allows all origins is equal to true make sure you add this line as well nothing uh much in this file now so these are all things which will be requiring you can just see what of what all things have added and yeah this is the only file which you will be uh changing in this video there's nothing much we are doing in it we will be going step by step so first change add this the second is this third you will be adding these two lines in the middleware right after that you can directly add this causal of origin is equal to true and at the end you will add this piece of code so for all this uh i'll give you a brief explanation in the further videos but for now just add it yeah so this was it for the configuration of these two both libraries which we have installed and the rest stays same so yeah this was it for this video guys uh in the next video we'll be looking into how you can store media files within your django app so that will be also a configuration part and nothing more on it so yeah this was it for this video guys if you have any questions queries and concerns please feel free to comment down below and thanks for watching
Info
Channel: Okay Dexter
Views: 5,262
Rating: undefined out of 5
Keywords: reactjs, tutorials, okaydexter, simple, http, get, post, request, httprequest, easy, mrbeast, like, subscribe, devto, coder, code, put, delete, modal, signup, form, loginform, videomodal, videos, guide, youtubeapi, dataapiv3, searchapp, github, demoapp, api, carousalcomponent, emojicomponent, html, emails, demo, video, nodejs, javascript, example, reat api, rest, mockable.io, json, data, expressjs, web, staticsite, middlewareexpress, nunjucks, Django, fullstack, react, adminpanel, commands, restapi, corsheaders
Id: Co-bXuanfP0
Channel Id: undefined
Length: 8min 34sec (514 seconds)
Published: Mon Feb 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.