Create Read Update and Delete (CRUD) Functions | Django Inventory Management System Web Application

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone this is kennedy from cambridgetech and welcome back so in this part of the tutorial we are going to work with the products view okay this session over here we are going to see how we can read or fetch data from our database and display them here we are also going to see how we can add data through this interface right over here then we are also going to perform the basic functionality i'm going to speak about very shortly so we'll learn how to delete an item from the database or edit an item based on what we've added from the session so first of all let me open the admin panel so that we see exactly what we have at our back end so at our back end we have products over here and that's what we did when we wanted to add in data so this is the kind of data we have in here and we are not seeing them here because we haven't connected or we haven't written queries to see that but even before we go into that detail let me also show you something briefly so there's a uml a concept in software engineering principle which kind of interprets the functionality that we are going to have in the form of a diagram so that it makes things very easy for us so what we have over here is we have two instance of a user for application so this is our inventory management system and we can have an admin and we can have a staff it doesn't matter where you place them they can be on the same side but the most important thing is where they connect to as far as these notes are concerned so what you have over here is some kind of activity that they can perform so for instance an admin can create products okay but a staff cannot create products or a staff cannot add a product onto their database but then an admin can do that an admin can update and an admin can delete a product from the database now we also see that a staff can make a request so for the purpose of this application an admin cannot make a request it is only a staff who can make a request a staff can view the products or the products same as the admin can also view all the products a staff over here can view his or her profile an admin can also view sof profile but we can see that an admin can view all profiles so an admin can view his profile in addition to all the profiles from all the staffs usually about 20 stops within the system an admin has those privileges to view all those profiles now an admin can also assign privileges to setting users so that they can also either become admins or can perform some kind of functionality within the web application so having said this remember we've already logged in as an admin over here so let me just log out and log login we have admin one and this is my password so if i log in this is an admin when i come to products like you saw over there an admin can add a product an admin can delete a product an admin can edit a product we are going to see the functionalities very soon and things of that sort good so this with the admin but then if we should log out and log in as a user so i have a user by name mary and i'll type in the password of mary but when i log in as mary these are our static data you're not getting anything from the database you're going to work with this very soon so as you can see mary writes at the back of the interface mary has mary cannot do um an addition of a product or a deletion or things of that so but then america making a request and that's how we design this application so let's come back here into our admin dashboard and let's go to product so this is where we are going to write the logic we need to implement some of these things so first of all let's look at how we can fetch data from our database and read them so as far as the jungle architecture framework is concerned if we would want to interact with a database we definitely need to write in some sql as far as talking to our databases content yes we can do same with jungle but then we have other alternatives and the alternative we use i mean pretty much the standard over here is the orm so orm stands for object relational mapping remember the items we have in here are the objects okay so there's some kind of mapping or there's some kind of relationship between the objects and django has a way of mapping it for us so let's say we have these products within our database and we have these categories and these quantities we are most likely going to make a database query and a database query is simply the way we interact with our database so how we interact with our database we don't want to see something from the database or we want to add something to the database i mean an object or a product to the database we also want to delete something from the database or perhaps we've already added something but now we want to edit and conventionally database queries associated to crack functionalities so the crap we see over here is an acronym that stands for create read or retrieve as some people may want to call it updates and delete so now basically this is everything you might be doing with any web application so far on the internet there are other functionalities but then these are the core fundamental ones so take twitter take instagram take youtube take facebook for instance so now let's go to facebook or assuming we go to facebook we can create a post okay so what's on your mind okay the weather is too hot then you post it you've created some kind of data it has been saved in a database so you have created it then you can read what other people have created or what you have created yourself so you can go back to your profile and go and read remember you added the name where you work and things of that sort you can also update so for instance you are working with company a you've now moved you've changed location things of that sort so you want to edit or update your profile and that's essentially what you do over there then you can as well delete something so maybe you write in something posting a comment and you find that well this may be a little bit irresponsible or maybe it was a mistake maybe a typo you can delete so primarily that's what you do with i mean the biggest of all applications and this is what we are going to implement as far as database interactions are concerned so in most cases you are going to write a query set so a query set represent the collection of objects of a particular model assessed from the database based on a given criteria we are going to see some of these things very soon so over here by using the orm we can declare a variable over here so this variable is normally going to be the query set so the variable to hold the data what you want to collect from the database using the orm you can write products.objects.org so this product you see over here is going to be the module name remember you have three models we have the model for products we have model for order and we have model for profile and of course the user model is already inbuilt given to us so you can also use that as well so we can have the model name dot objects dot all so this dot all method will collect or will fetch all the data within that model we specified over here and save it in the variable that's we are using to represent the query set we are going to see examples very soon then we can also use the dot gets method so this dot gets met so get a particular object based on some parameters we are going to specify in here and in most cases you are going to get by maybe the first name or the id number or things of that sort they can also have the dot filter so remember we have categories in there we have stationery we have food and we have electronics so we can filter based on those categories and you are going to see examples as we move along and we can also have a query set where we are using the exclude so we are deliberate about excluding something we don't want to fetch that particular thing we are going to see examples as we move along so this is just a brief description of everything i've spoken about the org stand for object relational mapping so if you want to retrieve all data or all objects from the database we can do the modelname.objects.org so here for example we have two.objects.org retrieving a specific object with filter so you can filter through a category or some parameter we stated as far as the design of our model is concerned we can also retrieve okay so this is just a repetition of this all right so we are going to end here and switch into vs code and see how we can make good use of this orm that i spoke about so the first thing i would want us to look at is the read functionality as far as the credits concerns we are going to write in some query sets some logic within our product view remember this is with our products view so i'm going to come into vs code and first of all let me close all these over here good so i'm going to go into a dashboard app folder i'm going to views and here we have products they can start typing in some logic here so the first thing i'm going to do is i'm going to come to the very top over here and run an import so what i'm going to do is i'm going to say from the current models i want to import products so that we can have access to this products model over here and work with it so i'll come in here and i'll put up a query set over so we are going to look at two things okay or how we can use different methods so let's say we have this is going to be our query set okay i mean it is going to be a variable so these are query set items and you want to collect all the items from the product model and bring it inside this item variable over here or query set over here so what i'm going to do is i'm going to say products which is the model name dots objects dot or now if i do this we are going to have everything in here but before we do this we are going to look at other options as well but then let me come in here and come and pass in a context dictionary you've seen this before so what i'm going to do is i'm going to type in items over here so this is going to be our key and our value is going to be items all right let me bring the trillion and come over here and what i need to do is to now pass in the context inside the return value over here so this line of code is actually going to collect everything we have in our products model okay and this is our product model once again when we go into products these are the items we have we have hp laptop bag of rice mbo pen with these categories and quantity so what's we have as far as this query set is concerned we want to collect everything from the product model and save it over here we now have this context stationary over here and now we can have access to it in this product dot acm all over here now this is going to work but then let me before we look at this let me show you this we can have items and what i'm going to do is i'm going to say products dot objects and i'm going to say dot raw now as far as this dot raw is concerned this is the straw will then allow us to write in normal sql so when i see normal sql the normal sql that we know so as far as the normal sql is concerned you want to collect everything from products we can actually see select all and this all is going to be star select all from so where do you want to select all from now this is what i'm going to do i'm going to say dashboard underscore products so let me close this up so that we have this on one line and see now this is the normal query sql that we know but this is looking a little bit different now as far as the django architecture framework is concerned what we have over here online 22 as far as this dashboard underscore products concern is if you want to touch on a particular table in a database then we have to first of all put out the name of the application underscore the name of the model okay that's the convention it uses over here but then as far as this is concerned this is going to work so i'm going to save this and if i come here and come in refresh you're not going to see anything over here yet so what i'm going to do is i'm going to go into my templates and i'll go into products.html and this is where you want products display so first of all i'm just going to collapse everything i have over here for the table rules i'll clear everything i'm going to show you exactly how things will look like so if i clear everything over here and come and refresh yes this is just what i want i just want one row over here and that's what you see right so you have just one rule over here and now you want to render data over here instead of just this static data so we are going to use a for loop so this is for the table body we just leave this assistant because these are the headings so just before the row we're going to put out a template tag over here so we've seen this before and the template tag will enable us to write python logic or python codes over here so i'm going to say for item in items and it is prudent immediately you write your for or your logic you need to come and end it right here so i'll say n4 all right so this is going to work now where am i getting these items from these items are being fetched from the database so as far as loops are concerned this is the new variable we are declaring that we want to use and this is what we are fetching from the items over here okay you can have also done from items in items it doesn't matter so i'm just using from item in items then what i want to see over here is data so i'll use a double curly brackets then i'll say item dot name so when i do item dot name where am i getting this name from let's go into our models and we can see that as far as product is concerned we can have name category and quantity so that's what we are assessing over here so you can have a name category and quantity so i'm also going to do same over here i'm going to say item dot category and this category is small letter c and finally i'm going to do item dot quantity so when i save this and come back here to come and refresh we are going to see that yes we are getting in the data from the database itself okay so you have hp laptop bag of rice and bubbling marker you have this has been reversed okay so you have bob pen marker bag of rice and hp laptop over here all right so right over here we can add in a new product for the new product i'm going to say coffee cappuccino and there's going to be a category of food and the quantity i'm going to say 200. so when i save this right from the back end if i should come here and come and refresh we are going to fetch it over here so this works okay so as you can see we've actually written um let me close this we've actually written sql code over here like i said this is going to work this is also going to work the first one i had over here as far as using the orm is constant so let me put out a comment over here and i'll say using orem okay the object relational mapping method is what we have and right at the back of this um clearly the url is a little bit short in terms of the number of things you should write and it's quite descriptive because you're saying saying products.objects.org it's very simple makes a lot of sense then i'm going to say dot raw and inside here you are going to write sql um code over here i think this is better so we are going to use this and when i save and come back here to come and refresh yes we are still getting our data over here because this is i mean eventually the same thing okay so moving forward we are going to use the orm instead of the raw sql commands all right so clearly we are done with one aspect of it so we are done with a reading okay so we can actually read something from the database as we have over here now let's look at how we can add a product over here now you've seen this before in a different way remember when we were doing the registration it was also an act of adding something onto the database so you're going to apply the same logic over here so in order to make things work properly we are going to create a form in here remember the registration we had a form so we also going to have a form over here so i'm going to create a forms dot pi module over here then inside forms up i'm going to say um or i'm going to run this import so from jungle i want to import forms then i want to create a form for products i'm also going to import the products model over here so that i can work with this so i'm going to say from the current models i want to import now to import products so i'm going to create in a class and i'm going to call this products i'm going to call this product form and i'm going to inherit from forms dots model form so this is going to be very simple we are going to have a class meta and we've seen this before and it takes in at least two parameters so the first parameter is going to be the model and this answers the question which model do you want to create this model form for and the model is going to be products and that's the reason why we imported product over here and we also need to specify the fields so i'm going to put out a list over here and as far as the fields are concerned let's come into our module over here so clearly we can see that i want something for name we want something for category and we also want something for quantity and that's essentially what we have over here so so that we can have something for name quantity and category so we are going to go back into forms.pi and i'm going to say name and i'm going to say category over here and last but not the least i'm going to have quantity so i have this over here all right and i think that's just about it so we come back into our views and we import the forms dot pi module we just created over here so i'm going to say from the current forms i want to import and i want to import the products form that we just created over here now remember this form is still going to be on the products url so we are still going to have it inside here okay so what i'm going to do is i'm just going to come down here and write the logic that we need and um okay so before we continue let's go to this product.html and kind of see things work out properly so this is what we have this is where the form is okay so add products and this is some kind of static data you put in over here but since you are going to render a form i'm just going to clear this okay so i'll clear this all right and you've seen forms before we worked the forms before so when i refresh you're clearly going to see that you don't have those things over there so i'm also going to clear this and use a method of post because you're adding data so for the method i'm going to say post and let's start with the logic over here so inside views i'm going to say if request dot method is equal to post so if the request method is equal to post then the form that you want to render should be equal to the product form that we just imported and we want to grab in the request dot post over here else we just want to render the form empty over here so we want to see the products form as we have over here then what i can do is i cannot pass in the form variable we just created over here inside the context dictionary and this is why we need a contact this night so that's with just this name passed over here you can have access to the items which has to do with the logic we have over here and the form that we are trying to implement over here so if i do this and come back here and refresh we are not going to see anything yet because we haven't passed in the form in here so we can come in here and since the form is behaving like some kind of data we can [Music] yes let me clear things up over here so you can just put out this form over here so when i save and come back to come and refresh now you can see that we have this formula it looks crooked we are going to style it and we know how to style things up over here so first off let me just open things up over here and let's go to i think the register.html we have this load crispy form tag over here let's just copy this so ctrl c bring it up over here and all that we need to do is to pass in the crispy filter so i covered this extensively in i think some of the previous videos so i think it will do a lot of good if you watch out or check out those videos so just after doing this if i come back over here you can see that our form is literally styled over here we have the categories that we would want to work with as far as our model is concerned now we are not quite done as far as the logic is concerned so all that you said is if the request.method is equal to post you want to render this form all right so now let's continue and i'm going to say if the form dot is underscore valid so we are calling the valid order is underscore valid method over here if it is valid and i want to say form dot save so form.save and onto return redirect okay so you don't have to redirect over here we come to the very top of eye and redirect is in shortcut so we import redirect to vi we've seen this or we saw this when we were working with the register that's why i'm moving a little bit faster right so i'll call this redirect and where do we want to redirect to after saving perhaps after saving we still want to remain on this form so we are just going to put in the url for products and the url for products um i think that should be somewhere here so as far as product is concerned i think it should be dashboard underscore products let me go to the yeah so that's that's what underscore product so let me just copy this ctrl c and i'll just have to paste it over here all right and i think that's just about it as far as a creating of data is concerned so let me come back here come and refresh and now i want to create it and see it's listed over here so what i'm going to do is i'm going to say um samsung samsung tv and samsung tv is a category of electronics okay and the quantity um let's say we have 40 of them so when i click on add products yes we are getting this very good error over here so it says csrf token missing or incorrect and that's simply because we didn't pass a cs csrf token over here so this a security feature so we need to come and pass it over here csrf underscore token so when i save this and go back here and let me refresh so let me have samsung tv the category is electronics and the quantity you want to add 40 in here so when i click on add i can see that i have samsung tv is of um category of electronics and we have 14 over here if i come and come and refresh you're also going to see samsung electronics and category 40. so we've accomplished two things over here as far as the crack functionality is concerned we've looked at the read and that's what you are seeing over here we are retrieving or we are reading data over here now if also seen creates because you are creating data into our database now let's look at delete and edit and delete and edit is also going to lead us to some interesting things so as far as those ones are concerned i'll come in here and let me close these once again so over here what i'm going to do is i'm going to create new views over here because these are also going to implement some kind of logic then what i'm going to do is i'm going to call this function then according products i'll call this product and it's called delete and it's going to take in a request we've seen this before and for now let's return render and you pass in request over here and the name of the template is going to be in dashboard slash and we are going to see products underscore delete dot html so you're looking at the delete first and later you're going to look at the edit or the updates function so after writing this you also have to put in a url for it but as far as the delete is concerned now see what we are going to have over here we are going to delete a particular item okay and not just all of them we can actually look at how we can delete all of them but then in this case we are going to delete a particular item so there's a way we have to grab that particular item so what i'm going to do over here and i'm going to explain we're going to pass in another parameter we're going to call pk and pk is going to be the primary key of that particular item we want to grab so as far as the query set go i'm going to have a variable called item and i'm going to say products because i want to pick a product in there so product dot objects dots gets and now the question is okay now you are not using dot all over here as we used over here because you don't grab everything okay we want to get a particular item and what do you want to get you want to get it by the id so the id should not be equal to the primary key and there's a primary key i'm passing in over here as a variable okay i can say id is equal to id okay so this is what i have so now if i do this then clearly we can see that okay we are grabbing a particular item in here so now we have this we are not quite done yet let's go to our urls.pi because remember you've created a view a function over here you need to create a corresponding url for it so that it will be able to work with it so it's also going to be like the products view or url we have over here so i'm just going to copy this and duplicate this and change in some few things over here so i'll do ctrl c and i'll paste it just beneath it so i want to go into a route slash and i'll say delete i'm going to add some few things over here so it is going to be the view is going to be products deletes and the name of the url is going to be dashboard products delete so that's we have an extension over there so now you said we are going to pass in our primary key remember this request is going to be the product slash deletes we are going to pass in so if you are going to pass in the primary key then you also need to bring that primary key inside our url so what you are going to use is you are going to use the angle brackets over here and i'm going to say ins and a column and pk and i'm going to end the trailing slash you guys so this ends is basically saying that this key or this value you're passing is going to be an integer value okay so that's what we have right now when i save this and come in here and come and do delete okay let's just see something over here when we do delete it says out no it doesn't see anything like this and let's see we do delete for slash let's see nine see that product matching query sets where it does not exist so now let's come back here now when i hover around this okay when i hover around is just by hovering around this at the very bottom over here we can see that we have products slash and we have some number over here okay or even when i click on it you can see that we have this product slash one okay so now let's change this to one and if i do you can see that it says oh template does not exist at this okay so clearly the route is working but then we haven't created any template for it and it's true we haven't created any templates so remember in our views we said we are going to render this product underscore delete dot html we haven't created that one yet so what i'm going to do is i'm just going to um create that templates so that template is going to be products unless called delete dot html so with this particular template we also going to have these ones over here so let me just copy this ctrl c and come in here come and paste them and end my block content over here so i'll say end block so when i save this and now come back to come and refresh we can see that yes it is able to see some few things over here as far as our delete is concerned all right so now let's come back so we also need to pass in a form over here so what i'm going to do is we have and we're going to create this very simple we have a container class over here okay so as far as this container class goes let me just quickly run this over here so i have a rule and i have a call md6 and [Music] we have a border and i'm gonna have an easter egg and i'll say delete item so let's say we have deletes page then i'm gonna have an hr over here and let's have a bg white and let's have a p3 over here and as i've imagined top of five and let's do an offset of md3 so that you position this inside the middle i think we've seen this before so um we are going to see i mean what we are actually doing very soon then what i'm going to do is i'm going to pass in a div over here and the class is going to be an outlet so i have a let's let and i'll choose danger and i'm going to just put in an h4 tag over here and i'll say are you sure you want to delete all right so i usually want to delete and there's going to be a yes or no but then this yes i know it's going to be in a form so i'm going to have this and first of all let me choose a method method of post and let me have an input of type submits and i'll say on fame and let me put in some bootstrap classes over here so i have bt and btn and i'll choose danger over here and let's just have a form over here and csrf2king in here all right so let's kind of see exactly what's happening over here so let's do a first slash delete and first slash one all right okay so late item are you sure you want to delete confirm okay so now let's bring a console um link over here and this is going to link so let's do cancel so because we want to go back to the products page so what i'm going to do is i'm going to put out a template tag over here url and this is going to be dashboard that's products so when i save this i think this is good okay so let's add the bootstrap classes over here and we have btn bt and secondary when i save this and i'm back here or i have this when i can so you go back here all right so i want the situation when i click on this then we get to that particular page so we are going to go into products because this in the product and we are going to render that url inside the delete button so if i should come back into products product.html and inside this table that's where you have the delete button over here so now this delete button should send us to that particular url so i'm going to do this and i'm going to say url and the name we give that url if we should go back to our view is we have no go back to our url we have dashboard product delete okay i'll just copy this so that's i don't make a mistake over here paste it over here now when i save this and we try accessing it you are going to have some problems over here so it says reverse for delete or reverse for dashboard dash product deletes with no arguments not found okay so it was trying to access something but then it wasn't finding the particular primary key we passed in in our view so what i'm going to do is i'm going to say i remember we are passing in item over here so we can have item or have access to the primary key so we can say item dot id all right so when i do item dot id now i can refresh coming to the dashboard products everything looks cool now when i click on delete you can see that it passes it in over here okay so i have delete four slash five i can cancel this when i click on this i have delete first slash one i'll cancel this and you can see that everything is not working perfectly so now we have this working we are not quite done with our view over here or a logical value so we are now just saying that yes you want to grab that particular item but then what do you want to do with it so i'm going to say if the requests dot method it's equal to post okay remember the requestor method is still post because you're having access to some kind of data in a database i'm going to say item dots deletes so this is a method we are accessing over here and we want to return a redirect because after deleting we want to go back to the product page so return redirects and we want to have access to the dashboard slash products so let me save this and i think our dev server is still running we don't seem to have any problems over here all right so let me refresh this okay so now let's try and delete um let's see the ball pen marker so when i click on this and click on cancel yes i've cancelled it when i click on this and click on confirm you can see that i don't have bullpen marker over here the item has been deleted from the database and if i should come back into my do that over here consider bopping marker has been taken off so clearly now we can add and let me add another one let's say we have orange over here orange is a category of food and let's say i have 1000 oranges in here so when i click on add now i have orange here if i should come back over and come and refresh from the back end we have orange here now we can delete orange but then what if instead of typing in let's say 100 we made a mistake and typed in thousand and that's where we need to come and edit some of the things we have over here so now we are going to work with the edits functionality now the edit is almost going to be like what we did with the deletes okay in terms of um some of the things we did so over here we are going to creating um a view over here so or a function so i'm going to say products underscore updates and this is also going to take in a request and since i've explained this we're also going to edit on a particular item okay so you're also going to grab the primary key over here then i'm going to call let's first of all return return render and are passing a request and the name of the template is going to be dashboard or slash products underscore would that underscore um update dot html all right so over here i'm going to pass in the context but then we are going to look at it very soon so let me just pass in the context over here and let me close this up a little bit and you have the context down here all right so we have this we have a view over here let's go and create this html template over here so this is almost going to be like the product deletes um over here so i'm just going to copy this and paste this and change the name over here so i'm going to rename this into a products update dot html all right so i have product update.html we are going to change some few things over here but the most important thing for me now is to go and create the url so with the url i come into my dashboard my application folder coming to urls.pi and this is also going to be like the products delete url so i'll just copy this and paste it over here and changing some few things over here so are changing the updates to delete um the delete to update we are also going to grab the primary key then the name of the function is obviously going to change as well so i'm going to choose products underscore delete sorry product underscore updates um function over there then i'm also going to change this to updates over here so now you have the update url working out now let's go into the product dot html and also change this link over here so from the edit let me just copy this because i think it's almost the same ctrl c and paste this over here and i'll change the delete to update all right so we can have this and if i'm to refresh so our dev server is down let's see exactly what's happening over here it says do that updates okay says the product slash updates views the updates module dashboard of views has no attributes products updates so let's come in here that's what we use okay so i didn't save this that's why as you can see so i'll do a ctrl s over here and i think yeah it's working now so let's come and refresh and we don't seem to have any problem over here so now when i click on delete it takes me here now let's try and click on okay so the update 2 is working we just have to change the things we have in over here so for the updates let's go to let me just close these ones so for the products update view or for the template we don't want this i sure you want to do things over here we get rid of this and i'm going to say edit item or you can choose to say update item so when i refresh i just want to visualize things very well okay so now let's also change this to updates update and let's make this info as far as the button is concerned all right so when i refresh okay so you have this so now we are going to put in the form over here so as far as the form goes we'll come in here and come and write in some logic so you are going to say if requests dots method is equal to and you've seen this before if request or request method is equal to post then the form will be equal to the products the product form okay and we are going to grab the requests dot posts else we are just going to render an empty form over here so you're gonna see the product form just as it is over here so inside this context dictionary i'm gonna have form rendered over here so this is going to be form and yeah i think that's just about it so if i should come here and come and refresh and see that we have this form over here it does not start because we've not added in our crispy form tags so we are going to put in the load crispy form and i think i just have to come in here copy this so i'll do a ctrl c and i'll paste this right over here and apply the filter in here so the crispy filter is just going to be this crispy so when i save this and come back over here and see that we have this that we would want to edit now remember when we are dealing with um the profile edit page okay we already had what we wanted to edit pre-filled for us okay but then if we come in here and click on edit it is not pre-filled and that's because we've not allowed it to be so so we are going to add in i think just one line of code in order to get it pre-filled so within the product updates um page as we have over here i'm gonna grab the item so the item is going to be the products dots objects dots and i'm going to use that dot gets method okay we saw it over here and we want to get the id which is equal to the primary key variable we passing over here and this is now going to be an instance so i'm going to put out a comma over here and i'm going to say instance is equal to the item so the instance is going to be this item and over here so i'm going to say instance is equal to item all right so now let's see how this will look like so when i save this and come back over here let me come here first go to products and when i click on edit remember this is bag of rice food and a quantity of 200 when i click on edit we now have this pre-filled for us and we can now start editing now let's cancel and let's complete our logic because as it stands if we edit anything and see it is not going to work well so down here after grabbing it i'm going to say if form the form you just created dot is valid and you've seen this before if it is valid then you want to see form dot c we are calling the dossier method over here i want to return a redirect we want to return back to the products page and the product page is going to be dashboard products like this over here okay so everything is working our desk server is working and let's see if this will actually work so let me refresh this okay we are good to go so now let's change bag of rice to let's say sack of rice and change the quantity to 100 so i'm going to change the bag to sac okay and the quantity of 200 200. now when i click on count so it doesn't affect any change let me do it again and we have sack of rice and we are changing the quantity over here 200 now when i click on updates you see that now we have sac of rice we have the quantity hundred and tenths of that so you can now edit anything you want to edit over here so the samsung you made a mistake it was supposed to be 400 when you click on updates now you have samsung tv 400 over here now if you should come here and come and refresh but then you can now see that we have um 400 instead of 40 over here so now we can see that we are gradually moving there we've seen how to be concrete we've already seen how you can read we've seen how you can delete and we've also seen how we can edit so this brings us to the end of this video now in this particular video we've performed or we've write logic to implement the basic crack functionalities as far as any application is concerned now we've seen how we can add or we can create data we've seen how we can read data and that's what we are seeing over here we've seen how we can delete data from the database and of course we've also seen how we can edit data from our database now you find this tutorial very interesting there are a couple of ways you can help me grow my channel kindly subscribe to cambridgetech and don't forget to hit the notification button so that anytime i release a video you'll be duly notified also share this video with friends and family who find this content very useful at cambridge tech we salem programming you can do it also don't forget to pass in a comment or ask any question that you so wish to ask thank you very much and bye bye
Info
Channel: KenBroTech
Views: 4,864
Rating: undefined out of 5
Keywords: KenBroTech, Web Development, Front End, Back End, Programming, CRUD functions functionalities, create read update delete data database, database queries, inventory management system, django crud, queryset = Product.objects.all(), queryset = Product.objects.get()
Id: FOdtZY5Cv88
Channel Id: undefined
Length: 54min 7sec (3247 seconds)
Published: Tue Mar 30 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.