Setup Django in Visual Studio Code and Run a Basic Application

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and welcome to another video from the channel and today we'll be talking about how we can set up a simple django application inside visual studio code so before we can start the tutorial it is very important that you all have python and visual studio code downloaded so you can head over to the official python website and download python the latest version for python and after you're done installing and downloading and installing python you can head over to the official website of visual studio code and download it for whichever operating system your machine runs either windows linux or mac os so once you have both python and visual studio code installed you can we can start configuring our python web application so let's get started so the first thing that you need to do is that you need to open a for project folder in your in your visual studio code so one you can go to the desktop and i can just create a new folder here and i can call it uh django project yeah so once i have a new folder created i can click it and i can select i can click on select folder so once i have clicked on select folder i can oh hit control launch the terminal using control until day so once i launch the terminal i can the first thing that i need to do is set up a virtual environment so [Music] as i have discussed in my previous video where i showed how to set a flask but if but i would like i would repeat it again for whoever has not seen that video yet that a virtual environment is like an isolated environment for your project so that any installations project files dependencies do not interfere with your other web projects or any other projects so we can go ahead and write pip install virtual env and once we do that it says requirement already satisfied since i've already have it downloaded we go ahead and create a new virtual environment so we can just do that with virtual env and then we give the name of our virtual environment which is which i'm just going to keep env so once we do that virtual environment has successfully been created so but then the next step is to enter the virtual environment so we can just do env script slash activate.bat which is just the command to enter into the virtual environment but this command is for windows so if you would like to if you are on a mac os then you the command you need to enter is en source env slash source space env bin slash activate so yeah so once we activate the virtual environment you can see that you have entered into the virtual environment so once we do that the next thing that we need to do is just down install django so we can do pip install and i want to download a specific version so i can just do 3.0 point and this is just a normal check nothing to worry about and yeah so we can just we can expect django to start downloading oh right right right you need to write yeah yeah so we can see that django has started django has is installing i just missed equal to here and yeah so django has successfully downloaded the next command that we the next thing that we need to do is create a project so let's look at the django project file structure so django is a little unique when it comes to the project structure so what so what uh the hierarchy is is that think of your django project like uh the main the root of uh look at think of this hierarchy as your entire django project so if you had a normal website your main project will contain several app apps within it so if this is your main project so think of this for example as a normal website then app one could be a blogging section app 2 can be a social media interaction section app 3 can be a chatting application within your app that allows users to interact with each other so you can have separate components of your app of your project of you you can have your separate components of your project divided into apps like this so your application remains a decoupled web application so once it is d once it is a deep decoupled web application it can be used as a component in another project so this is what makes django really helpful since once you have once you have for example a blogging section created in this in one of this app you can import you can export it to another app and your and uh yeah you won't have to code it again so yeah so now that we have understood the structure we can go ahead and type the command to create a project so the command to create a project is django admin start project and once we do that we can just name our project so i'm going to name it my site once you've named the project another check by the antivirus just routine yes and yeah we can see that my site has been successfully created so once we do that then the next step is to enter the directory so currently we are in the django project folder so we need to enter into our myset directory so we can just do cd my site and we are into the directory so the next thing for us to do is to run a command called python manage dot py migrate so another thing that we need to discuss is that every python app every every django app has a file called models.py which contains all the database tables so we need to perfor and django has its pre-installed apps so we need to perform those migrations for which we need to use this command called python manage dot py migrate so we click so we type python manage.py migrate and if you get an output like this then it means that you've successfully performed the migrations so yeah so once we have done this we just we can just simply go ahead and run our development server everything looks good and it should work so we click we type python so the command to get our development server running is just simply python manage dot py run server so once we do this our python web application should be running at port 8000 at on localhost so we can go ahead and check and yes the install works successfully congratulations so this was just a simple tutorial on how you can get your django application set up in visual studio code so in further videos you'll be exploring more complicated topics on how we can rend how we can use html templates how we can add styles to them then and then we can build some more projects like a blog application etc so thank you so much for watching please like the video subscribe to the channel it really motivates me to put more content and once again thank you for watching
Info
Channel: Code Void
Views: 84,063
Rating: undefined out of 5
Keywords: Django, Visual Studio Code
Id: eJdfsrvnhTE
Channel Id: undefined
Length: 7min 35sec (455 seconds)
Published: Mon Apr 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.