We saw how the project & application was created, we had followed some steps with cmd, how we had made the project & application.
We had also understood its file folder structure in the last Django video.
Now today, we will see how to work with the Django Admin Panel.
Django has an admin panel, okay, how to work with the facility provided by Django, how to set up, I’ll tell you everything step by step again.
But, first of all, the previous video about creating a project & application is compulsory because we are going to follow the same steps we followed in the last video.
So you need to know those, okay.
To begin with, let’s know what the Django Admin Panel is.
Django Admin Panel is a Ready to Use User Interface.
Which is already provided by Django.
That means, you don’t need to design a UI.
Django provides you with an Admin Panel wherein there are all the functionalities an admin should have.
Meaning you can give permission to which user through which particular admin panel, you have to work with which table, you can access any table you want, you have to give permission to any user that this particular user has to work with certain permissions only.That the 2nd user has to work with certain permissions only.
You can decide that from here.
Meaning, you can provide permission to a particular user from a particular panel or you can access any table to do your work or you can also grant a set of permissions so that the user could work within certain constraints. This means that you could decide which permissions you want to give and to whom. The first user would work with certain permissions while the second user would have certain permissions.
Django itself provides an Admin Panel and it is very easy to set it up as well.
And the Django Admin Panel is a very important part of this Django.
When you are making your project, there is an Admin Site.
We will work along with the Admin Site by using the Django Admin Panel.
So guys, this Django Admin Panel is a very useful thing in Django through which we can manage our users.
You can create your own Custom Admin Panels as well but you’ll have to add your functionality while here, in this, Django is providing you by adding all the functionalities in this particular Admin Panel.
So we have to keep these things in mind.
Now let’s see how to set them up step by step.
First of all, what do you have to do?
You have to create a Project.
Like I told you in the beginning, those of you who haven’t watched previous videos in which I showed you Application & Project with configuration, please watch those videos first.
Because all of these videos are based on that video only.
So what do you have to do first of all?
You have to create a Project for Django.
After that Django project, you have to create a Django Application.
Now, this third point is new for you so I'll show that to you practically.
Also don’t worry, I am going to explain every step to you over here.
Now you have to Install Django’s Application in Django’s Project.
And then what you have to do is, there is a urls.py file in your project, which I told you about in the last video that there is a urls.py file available.
So you have to include your application in that file.
Meaning you have to include its URL.
Second, you have to create a new file in Application and name it urls.py
This file won’t be available in your application, you’ll have to create it.
I’ll show you practically how you have to make it.
First, I’ll tell you how to follow these 5 steps.
So I have made a folder here named Django Admin Panel, right?
Now you have to go inside that folder, and what do you have to write here?
I had told this to you in the last video as well.
As soon as you write CMD, this will open up here.
Now, this CMD opened up here.
What is the next first thing that we have to do?
First of all, we have to create a project, right?
So how do we create a project?
Let’s do it.
First of all, what do you have to write here?
Python - m venv myvenv.
This command was for what?
This command was for creating our virtual environment.
So just as I press Enter, a folder has been made on the backside.
Now what do we have to do with our Virtual Environment?
We have to Activate it.
What do we have to do?
We have to activate it.
How will we activate it?
My venv, meaning our virtual environment’s name, then Scripts, then Activate.
So what will happen? Our Virtual Environment will get activated.
How will we know that?
Can you see this here?
You can learn about Virtual Environment due to this particular thing, whether it is activated or not.
If this is not showing here, it means that your virtual environment is not activated.
If this is being seen, then your virtual environment has been activated.
Now what you have to do is, you have to install Django here.
How will you do that?
Pip Install Django.
As soon as you fire your command, your installation process is started.
So this is installed here.
Now what do we have to do here?
We have to create the Django Project first of all.
How will we do it?
Django - admin startproject, then project’s name.
You can name the project anything.
I have kept the project name as project only.
You have to put a fullstop after the space.
I told you the reason for the same in the last video, so please watch the last video once.
Just as I press Enter, you can see that 2 files are made on the backside, right?
Now what do we have to do?
We have to make an application.
How will we make it?
Python manage.py startapp and then application name.
Here too you can name your application anything you want.
I have named it App only to make it easier for you to understand.
Just as I press Enter, my app folder has been made here on the backside as well.
So what happened here is that only our Django has been installed, our project is made as well as our app is also created.
Now what is the third point?
Install Application in Django project. Okay?
How do we have to do it?
First of all, what do we have to do?
We have to open our VS code.
How will you open VS code?
Code space dot.
Our VS code is open, right?
Now here you have to go to the Settings dot py file.
Here if you go a little bit down, you can see Installed Apps.
Here, after pressing Enter, you have to write in single inverted commas, the name of the app, meaning, the name with which you have made the Django application, you have to write that name.
I have made a folder named App so I wrote the name App and then comma.
So what is this?
Application installed in Django Project.
I have written this hint so that you can understand it properly.
Now what you have to do is, Include, our 4th point, what is it?
Include application url in Django Project urls.py file.
That means that in our Django file project, there is a file named urls.py in which you have to include your application url.
How will you do that?
Here you can see your urls.py file in your project.
I opened it.
You have to go downwards here.
Then you have to import one thing near the path, which is include, right?
If any of you is not able to get the suggestions, then in VS Code, go to Help, in that go to Welcome, right?
Here, whichever functionality, perhaps python or some other language, you have to install that here.
If anyone can’t see the python extension, what do you have to do?
You have to go here…here is your python extension.
You have to install it here, right?
As soon as it will get installed, your VS Code will restart once.
After it restarts, you will get python’s functionality in the VS code.
You will have to restart your VS code once.
So I included it here.
Now what you have to do is, go to path, our first parameter, our double inverted commas, you have to leave it blank.
Why do you have to leave it blank?
Because your request will first be in your project, and then it will go to your app.
I had explained this Django Architecture to you, right? During Introduction to Django.
So you have to see that here.
Then write Include, and then in single inverted commas, first you have to write your app name.
What is my app name?
It is app.urls. You have to write that here.
What will happen when you write that here?
This will be your app url, that is your application url included in Django project url.
So what you did here is, that you included your application url in your Django project.
Now what do you have to do?
What is the last point?
Create one file in Application and name it urls.py file.
So you have to go back to VS Code, right click on your app folder, New File, and what do you have to name the file?
Just as you press Enter, your file is ready.
And then what you have to do is, from the urls.py file of the project, you have to copy this portion, right, and paste it here and then remove this part.
Is this much clear to all?
So what did we see so far?
We saw how to install an application in a project, how you have to include your application in urls.py file, and how you have to create urls.py in your application.
Now we will move forward, okay?
Next up, what do we have to do?
We have to Migrate Django Tables.
Essentially, Django has 10 tables of its own.
It belongs by default so it is compulsory to migrate them.
So what does Migrate mean?
Your database means the database of Django, the tables of Django are scanned into the database, it commits under the database.
We had used the commit function in Python with database connectivity.
So in one way in Django, if any table has to commit in the database, then you have to use this command - python manage.py migrate.
You have to fire that command, okay?
So what this command does is, it migrates all your Django tables in your particular database.
What happens is, whatever necessary tables are there in the Admin Panel, through which your Admin Panel is going to work.
So it creates those particular tables in the database.
Database is provided by Django itself.
Let’s see with the practicals, how this command is fired.
Open CMD. okay?
Virtual Environment should be compulsorily opened.
Then you have to fire your command which is Python manage.py migrate.
As soon as you press Enter, you can see this…these are the Django files.
And if you see behind in the project, a db.sqlite3 file has been created.
Which means that Django has created a database file.
You have to do this compulsorily because then only your admin panel will start.
Without this table, you cannot access your admin panel.
So we migrated.
Now we will create a Super User.
But first of all, what is Super User?
Super User is 1 type of main Admin who has all the authorities, all the permissions is called Super User.
So what you have to do is, whenever you open the Admin Panel, okay…
To open the Admin Panel, you have to Login first.
I’ll show you practically how we will get it.
We did the migration.
Now what do you have to do?
You have to run the Python manage.py server.
What do you have to do?
You have to run the server.
So what is Django?
It is a web based framework which runs on a particular server.
Did you see here that the server got run and it provided us with a url.
Can you see this url?
You have to copy this url, okay?
Press Ctrl + C only once, because when you press Ctrl + C a second time, it will stop your server.
Keep this thing in mind, okay?
And you have to go to the browser, go here, and paste this.
When you press Enter, it will show you that Django has been installed successfully.
But if you want to open the Admin Panel, then how will you do it?
Slash, then write Admin.
Just as you press Press Enter, this interface will open up where it will ask me username & password.
You will have to create this particular thing.
Right now, you cannot enter with any user, okay?
It will ask you to create a username.
Your username and password is not yet created or corrected, you have to create it.
First of all, I’ll explain how to create it.
Now what you have to do is, you have to create a Super User.
Create what? A super user.
How will you create a Super User?
First and foremost, without Super User, you cannot access the Admin Panel.
I showed that to you practically.
To create a super user, you will have to fire this command which is -
Python manage.py createsuperuser.
You have to write this createsuperuser combined, without any space.
How will we do it?
Let’s go to CMD, right?
Firstly, we’ll stop the server.
To stop the server, press Ctrl + C, right?
And you have to write a command that is Python manage.py createsuperuser.
Press Enter and it will immediately ask you for credentials.
If you want to keep the username Admin, okay, or you want to put your PC name, you have to keep it blank.
See, here it is mentioned ‘leave blank to use admin’.
If you want to name it something else, you can type it here and if you keep your PC’s name, then leave it blank.
The second credential will be an email address.
Entering the email is mandatory as well but there are certain validations in it.
You must mandatorily use @ in the Email ID, okay?
This is the first framework which gives validation under CMD.
It is compulsory to write a password and it has its validations as well.
Your password should not match your username.
Whatever name you have kept, should not be included in the password.
Your password is supposed to be of 8 characters.
I have written a password but you can’t see that in CMD.
Remember that also.
As soon as I pressed Enter, what did it show?
Superuser created successfully.
So now you can login into your Django Admin Panel.
After doing all of this, you have to once again run your server.
Go to Browser.
Write down whatever name you had entered in CMD and the password that you have entered.
As you press Enter, you will be in your Django Admin Panel which has opened up.
So this is the Admin Panel in which there are users…
What is our present user?
It is Admin with this Email ID and it is Staff Status, which means it has all the permissions available.
So this is our Django Admin Panel through which we can access everything such as User management, Models Access, etc.
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.
Now when I meet you in the next video, we will see how to add models in admin panel and how to create the models.
Let’s meet in the next video where we will see models in the Admin panel.
To log in, go to http://127.0.0.1:8000/admin and enter your new superuser userid and password credentials (you'll be taken to the login page, then returned to the /admin URL after you've submitted your credentials).
We may use these credentials to access the admin interface once the admin user has been successfully created. To do so, start the development server and navigate to "http://127.0.0.1:8000/admin/" in your browser. This will take you to the Django admin login page.
Themesberg has built this Django Template on top of Bootstrap 5 utilising the latest version without a jQuery dependence. Django is a popular web framework with a default admin interface that is coded and actively supported by professional developers.
You can use manage.py if you forget your username. Create a second superuser with createsuperuser, then look through the list of Users to find the first one. Then log in as the old superuser and delete the new one.
No. The django admin is not meant for end users. The django admin feature's sole purpose is to aid the website developer.
where will i get code access for the project source code?
this course structure is very good. I suggest for learning to this website.
Superb and amazing 😍🤩 enjoyable experience.
Er Komal Gupta
thnku so much sir. after waisting so mch time in boring videos.i learned only from here.explained vry well and i will suggest evryone that learnvern is the bst online plateform where you can learnalot
ajax lesson was something like boring . But , learned a lot with the sunit sir . Just learned how to deal with ajax in django