Now we've created our user profile view set and connected it up to a URL we can
go ahead and test this in the browser open up the terminal window and connect
to the vagrant server by typing vagrant SSH and if your vagrant server isn't
running then type vagrant up before vagrant ssh to start the server then
switch to CD forward slash vagrant and run source tilde (~) forward slash env forward slash bin slash
activate to activate our virtual environment then let's start our django
development server by typing python manage dot py run server 0.0.0.0 : 8000
alright then you can load up the browser and you can head over to our profiles
API project at 127.0.0.1 : 8000 slash api
slash and we're going to put in profiles
Ok so we don't have a profiles URL because
it's not plural we created it as just profile so update that to just API
forward slash profile and you can see that it returns a list of all of the
profiles in the system so this is the profile that we created previously for
our administrator account
with this API we can create a new profile in the
system so let's test that out by clicking on the HTML form tag and then
let's create a new profile called test@londonappdev.com or feel free to
add any email address you like as long as it's different from the one that
exists already and then the name we'll just put in test name and the password
I'm going to type password 1 2 3
Okay then when you click post you should see
that a new object is created and we get a HTTP 201 created response and it
returns the response containing the object that was created
so now if we head over to the API slash profile again we can see that this item
exists in the database and if you want you can also check this in the Django admin
using the credentials that we created previously
so if we go to the path or the
server name slash admin hit enter and then let's login with our credentials
the credentials that we created previously and click on user profiles
and you can see that the new test user was created here as well so it actually
created a new object in the database via our user profile view set okay so we can
actually also retrieve the details of a specific view set by putting in the ID
of the item that we want to retrieve so if we put in profile slash one this will
retrieve this user here the user with the ID of one and it'll give us the
specifics of that user and it will allow us to perform put or patch
functions or even delete the user from the database so we can update the name
here to mark 2 put and it requires a password field so we will switch over to
the patch using the raw input so we will remove these fields here and just
provide the name and we'll update that to mark 2 and if we click on patch
then it will only update the name field instead of the whole object so you can
see that the name has been updated to mark 2 and if we go back to the route
of the profile API you can see that it also appears here in this list
okay so we've successfully created a model view set for our profile objects