WEBVTT
Kind: captions
Language: en

00:00:00.030 --> 00:00:05.759
Now we have our user profile serializer
we can go ahead and create a view set to

00:00:05.759 --> 00:00:12.809
access the serializer through an endpoint
head over to the views dot py file and

00:00:12.809 --> 00:00:18.449
we're going to start by importing our
models module into this file so type

00:00:18.449 --> 00:00:25.320
from profiles underscore API import
models

00:00:25.320 --> 00:00:26.780
what we're going to use for our

00:00:26.789 --> 00:00:33.149
user profile API is something called a
model view set the model view set is

00:00:33.149 --> 00:00:38.219
very similar to a standard view set
except it's specifically designed for

00:00:38.219 --> 00:00:44.370
managing models through our API so it
has a lot of the functionality that we

00:00:44.370 --> 00:00:49.770
need for managing models built into it
all we need to do is create our new

00:00:49.770 --> 00:00:57.149
Model View set by typing class user
profile view set and then we'll base it

00:00:57.149 --> 00:01:02.120
from view sets dot Model View set

00:01:02.120 --> 00:01:07.260
give it the doc string handle creating

00:01:07.260 --> 00:01:14.960
and updating profiles the way you use a
model view set is you connect it up to a

00:01:14.960 --> 00:01:20.729
serializer class just like you would a
regular view set and you provide a query

00:01:20.729 --> 00:01:26.130
set to the model view set so it knows
which objects in the database are going

00:01:26.130 --> 00:01:31.950
to be managed through this view set so
let's assign the serializer class by

00:01:31.950 --> 00:01:41.329
typing serializer underscore class
equals serializers dot user profile

00:01:41.329 --> 00:01:43.980
serializer

00:01:43.980 --> 00:01:47.280
and then the view sets that we're going to manage through this Model

00:01:47.280 --> 00:01:58.940
View set is query set equals models dot
user profile dot objects dot all

00:01:58.940 --> 00:02:03.740
The Django rest framework knows the standard
functions that you would want to perform

00:02:03.750 --> 00:02:09.780
on a model view set and that is the
create function to create new items the

00:02:09.780 --> 00:02:13.890
list function to list the models that
are in the database

00:02:13.890 --> 00:02:19.860
the update partial update and destroy to
manage specific model objects in the

00:02:19.860 --> 00:02:23.520
database Django rest framework takes
care of all of this for us

00:02:23.520 --> 00:02:27.660
just by assigning the serializer class to a model serializer

00:02:27.660 --> 00:02:32.880
and the query set this is the great
thing about the Model View set

00:02:32.880 --> 00:02:37.040
Ok so make sure you save the file and we can
move on to the next video when we will

00:02:37.050 --> 00:02:40.970
connect this up to a URL

