Now we have our user profile serializer we can go ahead and create a view set to
access the serializer through an endpoint head over to the views dot py file and
we're going to start by importing our models module into this file so type
from profiles underscore API import models
what we're going to use for our
user profile API is something called a model view set the model view set is
very similar to a standard view set except it's specifically designed for
managing models through our API so it has a lot of the functionality that we
need for managing models built into it all we need to do is create our new
Model View set by typing class user profile view set and then we'll base it
from view sets dot Model View set
give it the doc string handle creating
and updating profiles the way you use a model view set is you connect it up to a
serializer class just like you would a regular view set and you provide a query
set to the model view set so it knows which objects in the database are going
to be managed through this view set so let's assign the serializer class by
typing serializer underscore class equals serializers dot user profile
serializer
and then the view sets that we're going to manage through this Model
View set is query set equals models dot user profile dot objects dot all
The Django rest framework knows the standard functions that you would want to perform
on a model view set and that is the create function to create new items the
list function to list the models that are in the database
the update partial update and destroy to manage specific model objects in the
database Django rest framework takes care of all of this for us
just by assigning the serializer class to a model serializer
and the query set this is the great thing about the Model View set
Ok so make sure you save the file and we can move on to the next video when we will
connect this up to a URL