Django Basics ( CRUD ) Live Coding - Praveen Malethia

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so i think we are live now and in this video i am going to make a django website full full stack website with a good looking front end and in that website uh i'll be making all of the cred operations and so you can have a basic idea of how django works how to do how to create in the database read in the database and read from the database sorry and update from updating the database and delete from the database so basically trade are the operations which are like core functionality of any website and how to make a database schema and how to make static files working with django so before getting started so let's go to the django documentation sorry angle talks so before starting with any framework so you firstly search for the documentation and from here we can start with the so basically you have you all of the dependencies are or i can say requirements are you should have python installed in your system if it is not then you can correctly go to terminal and type python if this prompts comes then means you have installed python and you must also have the python package manager which is paper so if you will type it a pop sorry these type of messages will if these type of messages will print a pop-up then you're good to go with installing changu yeah so we should check with our so i'm going to use vs code for this and let's paste the command here so i have already installed django if you haven't installed django then you can directly do this pip install django so this is saying requirement already satisfied which means i have already installed and the version of this is 3.2 i am using the 3.2 which is the latest version of that and so how do we get started firstly we have to create a project how do we create a project here is the simple command let me just copy and paste it here okay let me clear the console so this is the command after installing django you will have access to this command and this argument and this argument as well so what this command do is this is the django admin command which and after giving this argument which will be the start project it will create a empty project in your file system and after after this argument you have to put the name of that project okay so like what will be the project if you like if you want to do a to-do application then you have to name it to do and if you want like any e-commerce website then you can name it like amazon or whatever you want okay so for this tutorial i'm going to use to do and let's start it as you can see after entering that it created a project file and these are the files that comes pre-built with the django as they have discussed like whatever the project will be there will be a manage.py file which will control all of our like which will manage basically all of our django project everything about django project okay and then there will be a root source source directory of that project which will be the like main directory of the project we can say and here is indeed.poi which you really don't care don't need to care about it and this is the settings.pi file which you have to deal most of the time okay and here is the urls.py and asgy and wsgi or whiskey whatever you call whatever you can call it and this uh this file post our django application this uh this file will need like whenever we host our website on apache server or nginx or g unicorn we point our server to this file so we can create a web server interface so as a beginner you really don't need to care about this all you need to care about this file and this file okay so all of our configuration will be in this file and all of our urls or you can say uh you can just comment remove that comment and all of our urls will be in this okay so now how to start the server we now you have to run if you install you obviously have installed python and python man sorry firstly we have to navigate to our project file sorry project directory and then you can navigate then you can use the manage.py file to start the server sorry we have run server command if we hit enter and it give you this message and let's go to that and yeah our website is now working so we have successfully created our website and now it is up and running and now how do we set up this how do we add our features in this like how where is our database so let me first go through the settings.py file and this is this is the base directory like using the path library we can we can get our name of the current directory and or you can say hello relative or absolute path i you can call uh whatever it is i don't know base directory which will point to this directory okay uh sorry this directory main directory and secret key you don't really don't need to care about debug is equal to true means we are currently in the debug mode so all of our errors will be printed in the console and as our in website as well if we do like here whatever you can say the page note found you can say that this is the requested url and all of the available urls are here so it will print uh some hints as well and some of the debugging uh debugging uh you can say diva it will help also help you in deepening so whenever you are in development you have to uh you have to set it is equal to true if you are if you want to move to production and then you have to set it to false so let's stick to the true and this allowed host means which you really know don't need to care about for this video and here are our installed app so over all of the features will be mentioned uh included in this so that we can say uh we can mention our django project that we have installed these type of these apps so it can work with that so these are the middleware which you really don't need to care about as a beginner and this is the root config file like it will pick all of it this urls from this file okay to do dot urls and this is to do if you go then urls okay this is the template so with the help of this variable you can configure your static files okay and risky application you don't need to care about and this is the database variable in which you can configure all of your database like if you want to set up multiple database and then you can set up multiple database as well and if you want to stick to the one database which is sqlite which come by default with django so you can for testing or to look just learn stuff you can stick to that and if you want to move to production then you can use postgres and this is uh so setting up postgres will not be the part of this and i will surely do a video to set up how to set up postgres on this okay and here is a our language utc line you can see here asia if you're from india then you can set here asia kolkata i use tanzania for false and it will use now the indian time zone okay so here is the static url and django auto field okay so these are the variables which you as a beginner don't need to care about and so so this is the thing and now what you should do to start working on the website like you really don't just want this you want to work on some feature you want to some static page your home page the html code which you will write okay so for that you will have to write manage.py startup so let's go back to the documentation as we did run server it did the same we have done this so create the pulse app so basically this is just the project file okay and this is used to contract uh control the whole project and what so if you need any feature or you can say if you visit facebook like facebook is the whole project in our case to do is the whole project okay so if we go to this profile then this is the separate app for this okay facebook have a different urls for a different module or you can say different app for this project and like facebook have like it's not mandatory that facebook only facebook have all of the like websites have this type of separate module in which they install all of their features so let's start app like whatever we can call this like my app you can or now you can call it my app so what this command will do so this command will create an app within your project and with some files in it okay these are the migrations which you really don't need to care about for this time and this is the admin which i will tell you later on and in this models dot py you can write your schemas okay in this test file you can write your test for you can write unit test code for your applications or application whatever then in this views dot py you can write your logic for views okay so now before getting started with any app what you have to firstly do firstly you have to do so firstly we have you have to create a database schema okay so for database schema you will need to create a class with to do and now it will inherit models dot model okay we are saying so let me just correct the indentation plus to do and so what we want to save in our to-do list like what will be the name of name of the task which you want to do okay you can here say task name and models this is this is the models and this is the mall one or same thing and this is the character field which which say that we want to save a character like character string or whatever you can say it is a character or string character is just a one word string is a whole collection of length and maximum length how much length we want to store for now let's say 200 and if the task is completed we have boolean field okay boolean field and for default whenever like well let me just complete default is false and created is equal to model a type field autonomous equal to true f string under method like it will return self dot task name okay so this is the whole database schema for our to do like we want this will create a to-do table in our database and with the this attribute or you can say not an attribute this will create a row sorry it will not create it is the attribute of that table and this is also and this is also in which in the to-do table we want to stay uh store our name of the task and mark if that is completed or not and we also want to store that the time when it is it was created so for storing task name we are using character field in which like we will use something something like this like this to do like make a youtube video like if we want to store this then we have to use our character field which is this if you want to store true or false then we have to use like if you want to use any boolean value in our table then we have to use boolean field and to store any date time i'll like timestamp values then we have to use datetimefield okay and we also have date field as well okay for now we are going to use at the time so default so whenever the new task will be added it will be not completed completed will be false by default okay so and whenever the task will be created hey just a minute whenever the task will be created and so that time at time at that exact moment will be added to that value okay will be added in that value so firstly we need to migrate our app so for this firstly let's migrate whatever comes with the django so django comes predefined uh jungle comes with the user's users tables session tables and many more things so firstly you have to run this command migrate that's good so now we have to run make migrations it will not pick up that obviously because why why didn't pick up because we don't have registered our app how do we register our app so go to our installed apps so you and usa here my app then don't forget to add a command so just a good practice so if you do make migrations it will say create model to do which is our name of our table okay model you can say whatever you want on table or model so in jungle we call it a model and now you have to run rerun migrate command so it creates a table for to do okay now it has created a table and django comes with admin by default admin panel if you go to the admin panel solve first first let run the server so it has created all our so sorry here's after just adding admin we have visited our admin panel and here it's asking for users cadet credentials like admin id and password so we haven't created any so and we will create our sales edit to do on manage.py this is the create super user command with with the help of this command you can create a super user so let's just create one i will say admin skip the email address sorry password will be administered one two three admin are there one two three okay password too similar we want to continue yes okay and so now we can say admin and administrator one two three so now we have visited our django admin panel we have been authenticated to our django admin panel so if you check the users then you can say we have the we have only one user which we recently created now with the username you admin and this is the hash value of our password so you can by clicking this form let me just enlarge this so if you can click this form then you can reset the password here here is a groups which you really don't need to care about as a beginner and now where is the to-do model so here here is is when the admin file of our app comes to in action so so we have to register our to-do model in our admin panel so we can see the whatever we are inserting in the database okay so here we have you have to import that from dot models import to do okay so now with this you can use here admin dot sorry admin dollar registered admin dot site dot register to do and here is our to-do's so if you will notice it automatically added s at the end of our model so it is just creating the plural value or i don't know what whatever we can call this so you can add to do name task name what will be the task name make a youtube video okay this is not completed by default stream return none type why this is the error i don't know why it's the error showing up sorry i forget the return statement so you have to return that okay if you will continue again then it is added so you can delete it from here now take me back and if you add another one so it is not completed by default if you check this then it will be completed by default so let's create another task which will be like start working on mumble so if you see this start clicking on mumble then we just marked as completed so it is completed and now where you should write your logic for your views and for this we have to so for writing logics or serving our static files we have to create our logic files or in this views dot py for this our for this app so let's start that dev index which will take request argument always and let's fix the indentation and what it will do it will return the render value of our request over the template and of the context which we want sent to the template so our template engine can render these values dynamically so we don't have these actually in define our function so we can say temple it is equal to index.html and for context will be m and after empty dictionary so a render a render function always take three arguments or you can say it at least at least it takes three arguments which will be request and then template and then context so request so this request is this request and this template will be a string value which will locate a template in your app directory and this context will always will be a dictionary remember that this context value will always be a dictionary so you can remove this and just insert an empty dictionary here okay this will also work so this will say in this is saying index.html so whenever you hit this so let's firstly import this from my app dot use import index so we are importing that and let's include a path in which we want to set empty path in which we want to return our index function okay so let's go to that visit our site it is saying template doesn't exist which is index.html so always try to remember this type of error so which uh so as i said when you will set the debug mode is equal to true then it will show you the errors which will help you in debugging so if i set false then it will won't show any error i think allowed host in allowed host you can say allow every host to render that server error 500 okay so this this won't help you in debugging so you can set true and you can you can keep this or you can remove revert it to back like empty it doesn't matter if you are in development mode okay so for now it is saying that template doesn't exist so where should this template be placed so you there are different ways but the ideal way is or the more recommended ways to create a directory in your app naming template and in that template you can create your index.html okay so let me just create a boilerplate for this doctype html html and here you can say head and here you can say body and in head you can say the title which what the title will be like set to do and in body you can say h2 welcome to your to-do list so if we try doing that it still isn't working so let's try to refresh our server it should work i don't know why it is not working oh yeah the name should be templates okay it's not template is this it will be a templates folder always remember okay [Music] template should work i don't know why just okay in the url and i just correct my app yeah that was just uh so i think which was not refreshing so if you see the source code or you can say here is the source code option oh it didn't see any so as we defined our doctype is html and head is the word which is the title we set to do and our body will be sorry i don't know why it is inserting all of that and in our s2 we have our to-do which we just inserted here sorry where is all we just insert it here okay so that's for our rendering files now we want to look it more elegant or you can say more cleaner so we are going to use materialize css for this and you can say get started so this is just a css framework and you can download this and i have already downloaded that so what i will do is just go to my pc and i will just pick up this so how do you set up your setup your static files so in your in one of your app you can create a folder like static in which you can put all of your static files and here is our index you can put your index in your templates yeah just replace that so here is a whole bunch of the html and you need to configure that it will not just pick up like this so you need some configuration to work with static files so let's for now just let's visit this so all of these are broken so if we see that demo of this this should look look like this but it isn't looking like this so what you have to do so in django to load your static files you have a tag which will be load static okay you have to type this if you don't have any extension you can install your django extension you can install all of these and after that whenever you will type load and then it will automatically sense that when you hit enter it will automatically add these opening and closing brackets okay so you will have to load a static and wherever your css files are so you can use this this and static and then we will then you will have to enter your path of the css okay so you can say static and now and same for the javascript you can just copy paste it here and in the end you can enter this this so let's see if it works or not no it still isn't working i think we need to start over yeah it's working so if it doesn't it doesn't work on your local server or on your machine try to refreshing the server and whatever you can try yeah bubbling getting started it will do that to the materialized css framework so yeah we are getting this and this which are same i think sorry so as you can see these both are the same so we have successfully loaded our template files so what should you do next now you should now you will want to render all of your to-do's here so we can for now we can remove the footer okay and we can also remove our icon section you can also remove that here so that's look a lot cleaner so instead of just logo you can do here to do to do and bar link you can also remove that if you want but you can still keep that like for this project we don't need that so we can remove so for this whenever we hit on to do then it will be redirected to the sorry it will be redirected to the home page it's like let me refresh so whenever we hit this and we are redirected to our to do like home page and now we want to render over all of the to-do's which we've added using admin panel so how will be at so let's go here and pick up a component or you can say javascript which you can drop down or [Music] they are in component collections so let's use this so you can copy this from here and put it to the thing here and you will hit reload then boom here are your static data to do refresh and let's say let's remove this we have only one now we want this data to be dynamic how we should retrieve the data from our database so oh as i said all of our logic will be in the views dot py so firstly so we you will have to import all of your data from to-do's okay so from dot models import to do so now what you will have to do so this is where django api comes in so like we can say to do's is equal to reduce videos to do dot objects dot all so this is our model and this is our model manager and with the help of dot all function of the manager we are importing all of the uh instance of that model in our to-do's okay so now you can print to those let's try running this and if you will see the console now we are having a query set instance in which we have a list of all of our to-do's so this is a list of our to-do's okay so if you are beginner in python and if you have done sort of python then you can for using for loop you can print however to do if i'll say refresh then you can make a youtube video start working on mumble and within here if that you can also print multiple things at the same time to do dot completed but it was the completed so you can just copy and paste it here and to do dot create it okay so make a youtube video which is not completed and this was created on this date and time and the second instance is started working on mumble which is finished true and this was created on this day so so for our console we can't just read this daytime value but our template can so the purpose of showing all of these is that with the help of that model model name and the objects which is the manager of that which this is made by default by django so whenever you are retrieving anything you always have to use to do the objects okay whatever the model it can be you always have to type the objects value or you can just simply like whatever your model name and then dot objects dot all or dot filter or dot create or whatever you want so let's give it back so how do we send our this data to this template okay so what this render function do is render our request use using this template and this data okay this data will be injected in this template okay so how you can so this is a dictionary so you can just simply do this to do's because so what what this do this this is the instance of to do's and we all of we are just injecting all of our to do's in a todos variable and this variable or this variable sorry or this instance can be used in this template okay we are using this and or you can say all to do's and you can name it whatever you want make sure it doesn't conflict with any other so in our in your templates you can just use a for loop so remember i am remember i am using a extension which i showed you earlier and with the help of this i just typed 4 and it auto completed everything for me so if you are if you haven't installed then you have to do it manually like this for to do in all to do's okay then you also have to end it and for and now you can put this thing in here and now let's try refreshing this okay so now we are having rendering our dynamic data from our database now this is not the actual data we are just we were just using like static video value and with the help of this like we used in our here like we used in our loop so this is just uh like a regular loop in python you can set to do and if you will refresh that then boom we are having our dynamic data from a database so if i add something more to database like to lose start start your homework okay we have added that so if we go back then we are having our third instance which we added just now so now we are having all of our data rendering in our template and now what you should do like so we have so let's say you have completed uh this task make a youtube video now you want to delete this okay so how do you how do you delete this so to delete this we can just use the delete icon and this will just use this and now what should you do now just redirecting so let's just keep it that way so now after clicking that you will after clicking that we will make a backend so that you are whenever you click that button so all of your your to do will be completed and it will be deleted from the database so like here here you can say make a youtube video delete as i am sure if you can refresh then boom is gone so let's take it back make a youtube video and hit refresh and then it's back and now how should you delete them so for that we have to make a different function which will create all of our logic for the delete functionality completed request and we are going to have an id like whatever we want to you know i will explain that just stick to me and to do will be to do the object dot cat id is equal to id so we haven't initiated any id but that's the beauty of the django django automatically insert a primary key which is id and increment it every time whenever we create any object so if you will see this take make a youtube video it have an id of four okay and if you go back start your homework have an idea of three okay so firstly com before completing this let me just make a url for that so we can say path delete or you can say complete and then id and here we want to say it make sure you always give a comment at the end of any list item so good our website is working fine so in this variable and now using this we can create our url which will be in index and in here you can just put simply put this make sure to add and slash before it so you can just use into an id here what you will have to do is curly braces like to do to do dot id id so let's refresh this and try to enter this and yeah that's a pretty good error which is saying that my apps completed didn't have written an http response it returned none instead because because we didn't return any type of like response from here we are just simply passing that values so now say id sorry let's take it back let's uncomment this and print to do's like just to do or you can name it whatever you want this variable you can name it whatever you want just make sure that it is just following the naming convention of python and now return redirect to our home page now we haven't imported this so you can just say from django.shortcuts import render and redirect as well so if we click on these again now what we are doing that visit this url if you look at here at the left bottom of the screen here if you look here then whenever i point this then you will see a url a dynamic url for every different to do like completed two completed three completed four so as these all are dynamic urls generated using id okay so using for loop we are just traversing all of our from all of our to-do's and naming it to do and with the to-do instance we can get the id of that instance and which insert automatically an id at the end of the url dynamically whenever i like traverse and so whenever you click these these are not deleting it why it is not deleting because we are what we are doing is just in urls we are saying that accept an argument which will be an id okay as an id this will be the integer instance and name it id okay so in here we are saying okay a request will come with an id so we can use this request and id in our completed function so with the help of to do from that table using objects manager we can get remember this always return single instance of model okay this will return a one value dot cat will always turn a one value and we can provide arguments from like which are like what are the fields we want to get the to do okay so the id is always unique in the django how it is always in it because django uses and mechanism to generate automatic primary keys which are started from one to three and goes on and on and on okay these are always unique so we can just use the id field to just get our filter our instance over to do so after that grabbing that instance we are just printing that to the console so if we try clicking that again so say start working on mobile if we click on that start your homework then we will say here we will see start your homework and when we click on make a youtube video and it will print over make a youtube video so yeah we are getting all of our instance using id or you can say we are grabbing our unique instance using id so now what you can do is to do dot delete done boom that's done here so if we grab this if we click here then this this will be deleted okay if you say delete boom that's deleted if you click here delete that's deleted click here that's deleted okay so in here template so we are not rendering any type of like condition that you have no urls so you can use the if condition here if if there is something in all to those we render these else else you can say s2 no tasks left to do as you can see no task left to do so this is the syntax how you can use your if condition in your templates okay you will have to type these syntax which are a ginger syntax you can say and remember whenever you initiate any these type of condition you always have to close that like we did with four like we started four and we ended that four like if we are just ending if and you can use if else with that you can just also work without that okay but that's not the correct way so now you will be wondering how do you add your to-do's not just by admin panel using a form so for that we will have to grab a template so using forms and text inputs copy all of these paste in here and let's try refreshing that yeah now we have our phone let me just zoom it out a little bit and now we have a lots of this element now we don't want these all of the elements so we can just remove these we don't want password we don't want our disabled we don't want our last name and we don't want only one dollar to do so if we said to do and instead of placeholder i should i should do and now we need a button also so let's fix this css and in here dot's probably up we want to add a button button if we thought type of submit and we can say at so now we are having a little button okay so to make it more stylish we can use glass is equal to btn btn green so you can see green and it will add some styling to that so whenever you click that it is the form is all getting submitted and with the form you can set the action argument which will be the current directory and you will always have to add a crsf token and you can manually type all of these if you haven't installed x extension and with post method sorry with method is called post so you can okay and we should name it whatever now what should we do we should name like to do task okay all right we got our phone and now we should make a url for that in here you can say path or you can do this without even a separate path in here you can add a condition okay if request of method is equal to post then what should you do like if the form is submitted like we are just hitting our home submit on this current directory like you can also say this if we add this this is always getting submitted to the youtube url and using that if we and at the current view if the request will be some if a post request is coming we can check this using requested method and now how should we okay just let's print out request dot post click continue and as you can see we are we were passing crs token which is this and in our to-do task we are passing this so where this to-do task came from later uh i added this name which is named task so this will be added uh this is added to this dictionary so if i refresh again okay let's get that if i add in here like make youtube video if i add this then you will see crf sub token and to do task make youtube video beautiful so now what should we do request dot post in that post we want to access our to task so let's perform it from terminal and let's print that out so make youtube video and now here you can see start working on bumble hat start working on mumble yeah cool so now how do you store that into your database easy you can just keep this you can store that value like task is equal to this and now you can just say print task whatever we are getting from our middleware sorry not middleware's front-end phone and we are entering this now what should you do so to create an object of that instance you have to do to do dot objects dot create okay so with all of uh so using this like model name model manager and create function you can create create an instance of that and what was that in the task name in the task name is equal to task so if i add make a youtube video i add and boom it's added so here we are just deleting that note marking as completed so so to get that so instead of getting all of the all of the instances let's make a filter here sorry not here we have to do it here so we also have a filter filter method which will do completed which we can pass completed is equal to false and it will basically filter all of our tasks which are not completed so it will complete them make a new video and we can just delete that okay they will start working on mumble add whatever you're like you can just simply add whatever you want and let's just delete these random values and no you don't want to delete them from your database instead you just want to mark them as completed and you also want to see the task that you completed not just delete so instead of just deleting that to do dot completed is equal to true and to do dot save okay so now this will modify the completed attribute or you can say complete the attribute of that instance and later save that so if you need to refresh now if we will go here complete it so now it is if we go to our admin panel now you will see we have our both of our instance and we are just seeing this why because we are just filtering which are completed so as you can see started working on is not complete so that's why we are only saying this and if you go back to start making video it is completed so we are saying that completed is equal to false but this is equal to true so we are not getting this value okay and and here we can say to-do's completed is equal to to do dot object.filter completed is true so let's add this to our template to those completed insert this okay so let's grab so we don't need to grab another one we can just use these if there are to-do's that are completed then if there are to-do's that are completed so all of the to-do's forever to do in every to-do's that are completed render them and add them add a value complete so yeah as you can see so if i just instead of the delete button we can just make it as check okay so now that's looking more legit or you can say okay so you haven't completed that so we haven't wrote any logic for this we just added that now we can go to our admin panel and save that making youtube video and try to modify that and if you refreshed it then boom we completed this complete this and we haven't make any logic for that so instead we can say on complete okay in urls you can say on complete and you can see here non-completed and you know your views you can just copy that and in here you can say non-completed and in here you can also import that from and we want obviously don't want just same logic we can set false value okay so let's try this oh it's working we say enter this so instead of just marking this we can say to do's completed to do's you have see to do's and we have here completed to do's and if you want to if we haven't done yet then we can mark that as not completed so that's pretty good and now what's left now so for now what we have done so now you have you now know how to create in the database and how to add it in the database and how to sorry how to read from the database how to update from the database and how to delete from the database and where is the create functionality for now let's summarize this is the our create functionalities here i can say create i don't know create let's take this create and here and here we are doing read and here we are doing read functionality and i am using obs sorry for your late reply okay let me just check some live chats all right i think i'm too late to reply to you dennis sorry for that so in these two functions we are what we are doing is we are just modifying the value of that instance so you can see here we updated something okay in these values okay so whenever you get an instance so you modify modify their attribute using dot operator and then you must save them okay and as i have known you so let's create delete functionality as well request and then id and then do is equal to get id is equal to id here you can say delete this is the delete functionality and you can say to do dot delete and now you can return redirect to the home page okay and we don't have any url for that for now you can use path delete and and id okay delete and now you can import that all right that's completed now so what's left for delete functionality okay let me remove that if these are completed then user can also delete them how do they delete so let's add one more icon which will be delete kids let's not add it here so let's firstly refresh it is completed and so one of our website is sorry one of our instance or you can say 104 to do is completed and now what you should need to do is let's give it a dynamic where is the oh here it is let's go to the second line and instead of here you can use delete okay instead of close you can say delete and you can give it a red icon sorry red no i am not using bootstrap i am using materialize css now let's refresh now this is a delete icon and you can simply remove that back here now if you click here you will see also the delete icon as well so if you will click delete it will be deleted from the database sorry and instead of nothing to let you do you can enter here like you have done nothing stop working on your things start king okay we can just say you have done nothing to start working okay you should do this now and if you click ok completed to lose now we are not having that warning and you can add class is equal to red text so that so let's remove this back to you have done nothing start working if you will click that here no left past left to do and you can add here class is equal to green text okay and green text if you remove back you have done nothing start working come on what are you doing and you should add here start making it a video it's not completed okay this completed so you can just if you are not if that was just by mistake then you can remove that back there and if you want to remove that now it's here so you can get all of these from all of that this code from my github so let me just upload this to my github new repo okay let's let me have to do which will create repository and let's just copies these commands and get in it so let me just add readme file fatal pad did not match any what are you saying get a readme. okay let's skip for that you can do this so if you have escort you can just do this so let me just um you can use get at and this will add all four files in our repositories and let's commit that and know what you will need to do you can skip this step okay but let's do this anyway get removed and let's put over project to github so yeah i think that the project is now completed so let's summarize this and what we have created updated and read and delete create update read or you can do like this if you really want just follow correct okay so we have created read updated and deleted from database so these are the basic code functionalities which you do from the database and here is the like base basic how to work with forms like you have to request dot method is equal to form and so to use like multiple forms you can or so if you want to use a base form like if you want to extend any form to another form then sorry not from extend an html to another html then what you can do is so you can come here and you can just say path dot join path instead of here sorry base directory with templates so what we are but we have done here so with the base directory which is our this join the correct uh join also the directory which is templates okay so we'll do here templates and in here so let's create base dot html and in here so just let me copy all of the code in our template let's just copy it here and what should we do for now now what's next and in our body you can define your block block content and you can just end it here and you can remove all of this from here so all of your content will be injected here okay so if you want to use like a base template for every page then you don't have to use like then you don't have to use like [Music] to do dot html so you don't have to copy and paste all of that stuff and then you don't need to edit just all of these like and you you will what this will do is you really don't need to import these file against okay again sorry these files you will not need to import them again so let me just do it here so you can remove these and these so you can use here extends okay base.html and you can say block content and as we have defined this content here i don't have so okay our terminal has a pretty good error so let's fix that in our base we don't have join just we have join path okay then you can run the server again so if you will see i hope nothing is broken and yep everything is working good as expected so if it's so everything every button is working and if you delete it here no task left blue you have done nothing start working okay and let me just provide the github link for this so yeah i think most of the work is done so this is the basic of that and in our next live stream what we are going to do is that user authentication and some navigation stuff like here you can place a navigation bar and doing some extra stuff so that's it for today's video and i will be joining you in this live and not in this life obviously new life okay that's it for today
Info
Channel: CodingVampire Praveen
Views: 358
Rating: undefined out of 5
Keywords: django, python, website, webdeveloper, django website, django python, python django, Python django, Django Tutorial, Django Basics
Id: 51uci9nM_MY
Channel Id: undefined
Length: 74min 58sec (4498 seconds)
Published: Wed May 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.