Create App With Django-Rest-Framework and Vue.js (Vuetify), Part II

In the first part, we created a project and connected Django-Rest-Framework, all the code can be viewed here.

In the second part I will write how to I watch how endpoints work. For example, let's take the endpoint for creating a user profile. 

# gcode_server/users/

path('v1/registration', Registration.as_view(), name='registration')
# gcode_server/users/

class Registration(generics.CreateAPIView):
    """Registration User"""
    serializer_class = UserCreateSerializer
    queryset = CustomUser.objects.all()
# gcode_server/users/

class UserCreateSerializer(serializers.ModelSerializer):
    """Create User"""
    password = serializers.CharField(write_only=True)

    def create(self, validated_data):
        user = super(UserCreateSerializer, self).create(validated_data)
        user.is_active = True
        return user
    def validate_password(self, value):
        except ValidationError as exc:
            raise serializers.ValidationError(str(exc))
        return value

    class Meta:
        model = CustomUser
        fields = ('id',

To work with endpoints, I use the Chromium plugin  Advanced REST client. The client is intuitive to use and has many options (save cookies, etc...).

In the client, we create a POST request

POST request

Create the fields of our request:

After sending the request, you can see the response:

You can see errors in the response (if they exist):

Post your comment

Popular Posts