Next we're going to test the Django admin now that we've enabled it for our
project we can test the Django admin by starting the development server and
heading over to our local host forward slash admin let's open up the terminal
or the git bash window and make sure that you are connected to our server and
you are on the correct virtual environment
then we're going to start our
management server or our development server by typing python manage dot py
run server 0.0.0.0 : 8000
hit enter and this will start the development
server and then we can open up Chrome or whatever our favorite browser is and
type in 127.0.0.1 : 8000 hit enter this will take you to the Django home page
and by default the Django admin is enabled on the forward slash admin URL
so if you remember in a previous video we created a super user for our account
so we're going to enter those super user credentials here if you type...or I'm going to
type mark@londonappdev.com you should type whatever credentials you
created when we ran the create super user command I'm going to put the password
is password 1 2 3 and then hit login so this is the Django admin and as you can
see you have three sections here each one of these sections represents a
different app in our project the auth token app is an app that is
automatically added or is an app that we added as part of the Django rest
framework when we enabled our tokens and the authentication and authorization is
part of Django and these come out the box with Django and allow us to use the
authentication system the app that we created is the profiles API and the
model that we registered is called user profile
Django figures out the name
of the model by basically looking at how you defined it in the class so you
can see that we've defined it as user profile so what it does is it separates
the camel casing which is the capital letters
that breaks up the words in the class name and then it just makes this one
lowercase and that's how it automatically generates the name and
because the best practice is that you make the class representation of the
model a singular so you notice how this is use a profile and not user profiles
plural the Django admin will automatically add the s because it knows
that in your user profile model you're going to have more than one item if you
were to define it as plural and put user profiles here then you would get an
extra s here and I will link to the documentation where you can find out how
to override this behavior if you like
okay so if we click on our user profiles
model you can see that we have the user profile that we created as our super
user so every profile that we add in our site will be accessible here in the
Django admin
if we click on our user profile you can see that the
first item is the password hash which is the hashed version of our password
notice that it didn't store it in clear text because it stores it as an
encrypted hash and then we also have the last login the super user status and
basically all of the fields that we have available in our model
okay so that's
the Django admin now that we've enabled it for our project let's go ahead and
commit our latest changes to git so we head back to the terminal or git bash
I'm going to create a new tab here and I'm going to do git add dot add any new files
and then git commit - am and I'm going to type enable Django admin for user
profile model alright and then do git push origin to push that up to github and
there we have it we have enabled the Django admin on our project