Hello guys, welcome to LearnVern.
In the last topic, we saw the installation of Django in which we had made a Virtual Environment & installed Django.
Right?
So today, we will see how to create a project and applications in Django. Right? Clear?
First of all, what is a Project? Right?
What you have to do is, you have to open your terminal in your project.
If you are on Linux or Windows, you have to open CMD, right?
You have to activate Virtual Background.
First create & then activate.
If any of you don’t know how to activate & how to install Virtual Environment, you can watch our previous video which is about Installation of Django.
Clear? Right?
So you have to see that video.
Those of you who know how to activate Virtual Environment & how to make a project.
How do you have to make a project?
You have to use this command which I’ve written in Bold -
Django - admin.
Now why is it written Django - admin?
Because it is 1 type of Django’s command so Django - admin startproject.
That also is a command.
And this myproject…
And this myproject is your project’s name, wherein you can name it anything.
Okay? Right? Clear?
Okay.
I’ll show you how to do it practically.
Alright? Okay.
So what you have to do is, you have to go in your particular folder, where we had created a virtual environment.
Okay.
Now if you want to activate the Virtual Environment, go to cmd first of all.
Right.
Write down your Virtual Environment’s name & activate.
Clear.
Right.
If you don’t activate your Virtual Environment, you won’t get Django’s support.
Why?
Because you have installed Django inside the Virtual Environment.
Okay?
Now what you have to do is, you have to create a Project.
So for creating a Project, you have to write a particular command which is Django - admin startproject and then project’s name.
Okay.
After you write a project’s name, press space and then you have to enter a full stop.
Why?
So that nested folders are not created Okay.
Suppose a folder is created, under that another folder is created, we don’t have to do that.
So it is compulsory to give space & add a dot.
Just as I press Enter, see at the back, a folder named myproject is created and we get a manage . (dot) py that is our Python file.
Right?
Let’s first understand how these files work.
Right.
So this is a kind of file folder of a project, okay.
Folder file structure, in which your project’s name is myproject.
Under which there is init . py.
Look, I’ll show you here.
In myproject there is init . py.
Right?
So what does init . py file do?
See, init . py tells you, It tells your particular folder that this is Python’s folder.
That you have to treat it as Python’s folder.
Okay.
Right.
Then you have settings . py.
See, I’ll show you settings . py.
Right.
What settings . py does ? it helps you indicate names, all your project configurations are here as well as all the settings of Projects.
Okay? Right? Clear?
Okay.
Then comes Urls. py file.
In which…I’ll show you Urls . py file is available here, right.
Now what Urls . py file does is - All links of your project and the function to call.
Which means as you keep making functions, as you keep making views, you have to put them in Urls . (dot) py.
When I’ll show you all of this further in practicals in Django while doing Crud operations & projects. That time I’ll show you this.
Right?
Right now, I’m just explaining the file structure & folder structure that how a particular file works and for whom it works.
Okay.
And then we have a Wsgi . (dot) py file.
Okay.
I’ll show you the wsgi file here.
Right??
What it does is, when you have to deploy a project, when you have to host, it is used that time for your project.
Okay.
And then comes Manage . py file.
It is on the outer side.
Okay.
See, it is here, right?
It won’t be in your project, it will be outside only.
What is inside it?
All your commands, such as how to deploy a database, how to scan, how to start your servers, okay, how to migrate your database tables into database, how to make the migrations…
All of that is handled by manage . py.
Okay.
So you will get all of these files made with the projects you have created.
Okay? Right? Everything clear?
How did we start the project?
First of all, we activated our Virtual Environment and then we wrote a command Django - admin start project, then the project’s name, right, then after pressing space & full stop.
And then you’ll get all the files here in myproject.
And we also got manage . py file.
Okay.
Now moving forward…
We have to create a Create Application.
So how is an Application created?
For instance, you have already created the project folder.
Clear?
In that particular cmd, you have to call manage . py & then with the help of that you have to make an application.
What is its command?
Python manage . py startapp and your app’s name.
Okay?
I have written myapp.
I’ll show you practically.
We have activated this.
Okay, we have made the project.
Now what will we make?
We will make our Application, which is - Python manage . py startapp and then app’s name that is myapp.
As soon as I press Enter, a folder will be created at the back named myapp.
Okay.
These files have been provided to us here.
Okay.
So let’s check the file folder structure as in what work the files do and for what they work.
Okay.
So, for what do these files work?
In myapplication, there is an init . py file.
Okay.
So what does the init . py do?
It tells you that this particular folder or package works for Python.
Okay.
Then, you have an admin . py file.
What is admin . py file?
It is used to modify Django Admin Interface, where we register models…
I’ll show you all of this by doing it practically for you to understand clearly.
Okay.
I’ll just explain to you the folder & file structure of the application.
Right? Clear?
Then comes Models . py.
What does Models . py do?
It stores the database models of whatever your web application is, it makes it there.
Okay? Right?
And then comes the test . (dot) py.
What does the test . (dot) do?
It works for Unit Tests.
Unit Test means after your application is made, the testing process does the Unit Tests.
Okay.
Lastly it is Views . (dot) py, which is the Backend I explained in MVT during the Introduction of Django video, right, I had explained it to you.
Those of you who don't know, I request you to watch that video first & you’ll understand it.
So views . (dot) py is for the application views, meaning it is used to create functions.
Okay.
Wherein we’ll create our functions and use particular functions there.
Okay? Right? Clear?
And if any of you have any problem or want any file, what you have to do is, you have to go to forums.learnvern.com & define your topic wise queries there and you’ll get your answers
And if you want any particular file, the files will be provided in the description.
Code files.
Okay.
If you have any queries or comments, click the discussion button below the video and post there. This way, you will be able to connect to fellow learners and discuss the course. Also, Our Team will try to solve your query.
When we move ahead, our next topic will be how to work with the Django Admin Panel.
I’ll show you in both ways, practically & theoretically, how the predefined Django Admin Panel works.
Okay guys, thank you.
Share a personalized message with your friends.