WEBVTT
Kind: captions
Language: en

00:00:00.230 --> 00:00:08.370
Finally let's test our view set in the
browser open up your browser and head

00:00:08.370 --> 00:00:15.269
over to the view set or hello view set
URL that we had open earlier and refresh

00:00:15.269 --> 00:00:22.230
the page to reveal the new post function
has been added to our view set so just

00:00:22.230 --> 00:00:27.990
like with our API view the Django rest
framework browsable API knows that our

00:00:27.990 --> 00:00:33.260
view set is going to accept a post with
a name because we assigned the

00:00:33.260 --> 00:00:38.940
serializer class to the top of our view
set and it looks at the serializer and

00:00:38.940 --> 00:00:43.920
it determines which fields we're going
to accept in the request that we

00:00:43.920 --> 00:00:48.780
make to the api and it provides them
here for us in the handy browsable api

00:00:48.780 --> 00:00:55.590
view so if we add our name here to the
input click post you can see that it

00:00:55.590 --> 00:01:00.750
generates the message hello and the name
that was provided if we put the name

00:01:00.750 --> 00:01:06.090
with too many characters more than 10
and do post then we see that we get the

00:01:06.090 --> 00:01:10.159
validation errors returned to us when we
make the request

00:01:10.159 --> 00:01:15.869
okay unlike the API view we don't
actually see the put patch and delete

00:01:15.869 --> 00:01:21.840
methods here on the hello view set API
that's because view sets expect that you

00:01:21.840 --> 00:01:27.180
will use this endpoint to retrieve a
list of objects in the database and you

00:01:27.180 --> 00:01:34.200
will specify a primary key ID in the URL
when making changes to a specific object

00:01:34.200 --> 00:01:38.369
so if we want to see these additional
functions that we added we need to add

00:01:38.369 --> 00:01:42.630
something to the end of the URL now in
in this case because we aren't actually

00:01:42.630 --> 00:01:46.470
retrieving any real objects it doesn't
matter what you type but if you just put

00:01:46.470 --> 00:01:51.180
a number here that would represent a
primary key of an object that you wanted to

00:01:51.180 --> 00:01:56.909
change and hit enter then it will change
the page to the get request which is the

00:01:56.909 --> 00:02:02.549
retrieve of that object so when you
specify a primary key to a view set URL

00:02:02.549 --> 00:02:08.520
it calls the retrieve function and as
you can see in our retrieve function we

00:02:08.520 --> 00:02:13.660
return this response HTTP method get
which you can see here

00:02:13.660 --> 00:02:20.080
in the browser then you can perform
various updates and delete functions on

00:02:20.080 --> 00:02:25.780
the different objects so if you hit
delete then it will call the destroy

00:02:25.780 --> 00:02:32.680
function that we defined which will
return HTTP method delete you can also

00:02:32.680 --> 00:02:38.320
perform updates on the object so by
default you will perform a put update so

00:02:38.320 --> 00:02:44.170
if we do a test input here and click put
you can see that it returns the HTTP

00:02:44.170 --> 00:02:50.140
method put and that will be from our
update function

00:02:50.140 --> 00:02:51.280
Finally if you want to

00:02:51.280 --> 00:02:56.320
do a partial update then you need to
click on the raw data tab here and then

00:02:56.320 --> 00:03:01.510
you can see you get the put and patch
options if you click on patch it returns

00:03:01.510 --> 00:03:06.550
the HTTP method patch and that's because
that's what we returned from our partial

00:03:06.550 --> 00:03:09.780
update function that we defined

00:03:09.780 --> 00:03:12.700
Okay so it looks like our view set is working as

00:03:12.700 --> 00:03:18.850
expected let's go ahead and commit our
changes and push them to github open up

00:03:18.850 --> 00:03:25.150
the terminal and open a fresh window
that is on our project and type git add

00:03:25.150 --> 00:03:30.180
dot to add any new files and git commit -

00:03:30.180 --> 00:03:41.880
am and we'll write the message added view
set to profiles API

00:03:41.880 --> 00:03:49.920
hit enter and then do git push origin to
push all of the changes up to github

