WEBVTT
Kind: captions
Language: en

00:00:00.030 --> 00:00:06.270
Now we've created our user profile view
set and connected it up to a URL we can

00:00:06.270 --> 00:00:12.480
go ahead and test this in the browser
open up the terminal window and connect

00:00:12.480 --> 00:00:17.609
to the vagrant server by typing vagrant
SSH and if your vagrant server isn't

00:00:17.609 --> 00:00:24.119
running then type vagrant up before
vagrant ssh to start the server then

00:00:24.119 --> 00:00:33.140
switch to CD forward slash vagrant and
run source tilde (~) forward slash env forward slash bin slash

00:00:33.140 --> 00:00:40.430
activate to activate our virtual
environment then let's start our django

00:00:40.430 --> 00:00:51.980
development server by typing python
manage dot py run server 0.0.0.0 : 8000

00:00:51.980 --> 00:00:57.809
alright then you can load up the browser
and you can head over to our profiles

00:00:57.809 --> 00:01:05.040
API project at 127.0.0.1 : 8000
slash api

00:01:05.040 --> 00:01:10.120
slash and we're going to put in profiles

00:01:10.120 --> 00:01:12.540
Ok so we don't have a profiles URL because

00:01:12.540 --> 00:01:17.369
it's not plural we created it as just
profile so update that to just API

00:01:17.369 --> 00:01:22.740
forward slash profile and you can see
that it returns a list of all of the

00:01:22.740 --> 00:01:29.280
profiles in the system so this is the
profile that we created previously for

00:01:29.280 --> 00:01:32.640
our administrator account

00:01:32.640 --> 00:01:35.640
with this API we can create a new profile in the

00:01:35.640 --> 00:01:40.590
system so let's test that out by
clicking on the HTML form tag and then

00:01:40.590 --> 00:01:48.450
let's create a new profile called test@londonappdev.com or feel free to

00:01:48.450 --> 00:01:51.689
add any email address you like as long
as it's different from the one that

00:01:51.689 --> 00:01:57.509
exists already and then the name we'll
just put in test name and the password

00:01:57.509 --> 00:02:02.740
I'm going to type password 1 2 3

00:02:02.740 --> 00:02:05.159
Okay
then when you click post you should see

00:02:05.159 --> 00:02:12.690
that a new object is created and we get
a HTTP 201 created response and it

00:02:12.690 --> 00:02:16.680
returns the response
containing the object that was created

00:02:16.680 --> 00:02:23.549
so now if we head over to the API slash
profile again we can see that this item

00:02:23.549 --> 00:02:29.610
exists in the database and if you want you
can also check this in the Django admin

00:02:29.610 --> 00:02:34.540
using the credentials that we created
previously

00:02:34.540 --> 00:02:36.900
so if we go to the path or the

00:02:36.900 --> 00:02:44.750
server name slash admin hit enter and
then let's login with our credentials

00:02:45.470 --> 00:02:49.950
the credentials that we created
previously and click on user profiles

00:02:49.950 --> 00:02:54.690
and you can see that the new test user
was created here as well so it actually

00:02:54.690 --> 00:03:03.689
created a new object in the database via
our user profile view set okay so we can

00:03:03.689 --> 00:03:09.820
actually also retrieve the details of a
specific view set by putting in the ID

00:03:09.820 --> 00:03:15.840
of the item that we want to retrieve so
if we put in profile slash one this will

00:03:15.840 --> 00:03:19.919
retrieve this user here the user with
the ID of one and it'll give us the

00:03:19.919 --> 00:03:24.389
specifics of that user and it will allow us to perform put or patch

00:03:24.389 --> 00:03:28.980
functions or even delete the user from
the database so we can update the name

00:03:28.980 --> 00:03:34.560
here to mark 2 put and it requires a
password field so we will switch over to

00:03:34.560 --> 00:03:41.940
the patch using the raw input so we will
remove these fields here and just

00:03:41.940 --> 00:03:46.739
provide the name and we'll update that
to mark 2 and if we click on patch

00:03:46.739 --> 00:03:51.449
then it will only update the name field
instead of the whole object so you can

00:03:51.449 --> 00:03:56.129
see that the name has been updated to
mark 2 and if we go back to the route

00:03:56.129 --> 00:03:59.790
of the profile API you can see that it
also appears here in this list

00:03:59.790 --> 00:04:07.370
okay so we've successfully created a
model view set for our profile objects

