Python Django MongoDB CRUD Tutorial (CREATE , READ , UPDATE , DELETE)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome to programming knowledge so i welcome you all to yet another tutorial programming knowledge in today's tutorial we are going to continue with more db uh uh last tutorial we i i had shown you how we can connect django with mongodb but now we are trying to implement crud operations the basically there are four card operations that is created update and delete and we are going to implement this using mongodb so first thing you can do is you can open this mongodb compose community edition and you can click on connect when you click on connect you can last in the last video i showed you how we created a demo database here then you can open the demo database and here you can see all the migrations the demo database has all the migrations we had done so you can refer to the previous tutorial how we connected mongodb to django it's very simple and it's very quick enough so i can also give you a quick view uh in settings dot py file you need to uh go into setting dot py file and what you need to do here you need to make sure that this database engine is jungle and you have to install them uh you have to make a demo database and the name of that database is very much the same demo database and you have to install a package called jungle so it can be easily installed while by typing the command pin install jungle uh for what uh for any like if you want to see it as a demo purpose you can refer to the previous video uh now what we are going to prevent the crowd operations so we will go step by step and we will see how we can uh create a app and then how we can implement the uh how we can implement the thread operation in that app so what you can do you can simply copy this or you can type on your vs code python manage dot py start app demo app so this would start a demo app uh inside your current project directory and now what you can do uh instead uh until the time it's been created creating a demo app i can show you further commands uh this is the one like uh uh i'll show you uh we are going to implement a database model so this how we make a database model we will make then we will create a super user and this is a administration i will show you that and i'll simply show you so uh okay so let's get back to our tutorial see the demo app has been created you can see the folder here demo app and it has a file called model.p wi-fi since i have created an app demo app i need to make sure that add this application here demo app okay now what you need to do i've already connected to my database and the next thing i'm going to do i'll move to models.pi file and i need to create my models here so simply i'll create a model and i'll make create a basic model see this one uh i'll copy this and paste it here instead of this i'll do class to do and this is the this is instead of first name i'll type task and instead of the second last name i'll do this to description so this is the description i am going to have task 0 modules and this is the description here i can increase the description to 100 perfect uh yeah okay now i have increased the description to 100 and now what we can do uh inside my admin dot py file i can register this and for that i need to do what i need to do i need to first import models from dot models import everything so i from dot models import star and here you can see that i have registered i can register a model here so i can copy this and paste it here yeah so here you can see uh i can uh you know import that model and register here as an admin so i can implement the third operation so i'll simply type to do so to do is the model which i have to register and i will create a super user at the same time python manage dot py create super user so this is the type of command i have to type to create the super user so it could ask me to like a username so here you can give a username as admin you can leave this email address password you have to give a very simple one and then again you can give a password the make sure it's an easy one just for the demo purpose and you can continue that and now so this password it seems to be too common but you type y that is yes and it will create the super user now since i created the model database model and i also registered that so now what i will do i will migrate this database python manage sorry python manage dot py make migrations and now what i'll do so here you can see it shows that create model to do now i'll migrate this python manage dot py sorry python manage dot p y uh migrate now i will migrate this database so yeah here you can see so uh i have uh made this and now what i'm going to do i'll go to my demo database and i'll refresh this okay so here you can see that i have got a demo app to do here here you can see demo app to do now what i'll do i'll run this app python manage dot py manage dot py run server okay now the app will start and start at the local host so i'll move to my local host so like we have created the model perfect we have registered as admin perfect and now uh okay this seems to be something else sorry uh yeah now i have created an app which i told you that and then we registered the app inside the installed apps directory as well so we are going in the right direction now i'm at my local host i'll refresh this and you can see that i have the my app successfully running now i will go to the admin slash admin so simply we refer to the documentation for the quick illustration of this and the you need to type in the username and password you have set and what you need to do then you can log in here and here you can see i have to do's so you can add a to-do here simply we are going to implement the cloud operations uh to do number one so a hello world i'll type simply type hello world anything you can give hello world and now i'll save this uh let me i'll either i'll do save and add another or i can save this yeah so this has been saved and here you can see the object says yeah this is i have the object okay so i i'm clicking on save again yeah but now when i move to my database i click on this demo app to do and here you can see that you have this data in the json format so perfectly fine so here you can see that i have the data in the json format uh since it's mongodb okay uh i'll quickly show you yeah you can see this in the uh json format so and this is the uh you can also click on this button so this will show you in the tabular form and this will show you and reduce some form it's perfectly fine so let's implement some few operations on that again now i click the do to do app project and i get to number one edited so i click save so this has been edited so when i move to my database i'll click on refresh i'll click here refresh button yeah now it says to do number one edit it now simply i can add another view so to do number two number two and i'll give the same description yeah and then i can move to my database refresh i'll get another one and now i can delete one so that makes a last purpose of our project i'll delete this yes i'm sure i'll delete this and i'm gonna move to my database i found it deleted so that's perfectly fine how we implement the code operations so thank you guys thank you so much for joining us in this tutorial so this was the quick purpose you can simply create a doodle app and with the database so thank you guys uh thank you for watching this video
Info
Channel: ProgrammingKnowledge
Views: 23,494
Rating: undefined out of 5
Keywords: Django Tutorial, Django Tutorial for Beginners, What is Django, Python (Programming Language), Python, Python Tutorial, Python Tutorial for Beginners, Python for Beginners, Python for Beginners course, program in Python, Python course, python tutorial, python scripting tutorial, Introduction to Python, Online Course, Python Guru, Learn Python, python 3, Full Python Programming Course, MongoDb, Django with MongoDb, CREATE, READ, UPDATE, DELETE, CRUD
Id: y2OgPMuRM70
Channel Id: undefined
Length: 9min 4sec (544 seconds)
Published: Thu Sep 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.