Search code examples
django-rest-frameworkdjango-rest-viewsets

By default, do DRF viewsets allow PUT, PARTIAL_UPDATE, DELETE, CREATE, LIST and RETRIEVE?


Suppose I create this viewset:

class UserViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all()
    serializer_class = UserSerializer
    lookup_field = 'username'

and this router:

router.register(r'users', views.UserViewSet)

and this serializer:

class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ('username', 'password', 'email')

Is there documentation that mentions if, by default, it does or does not allow user accept PUT, PARTIAL_UPDATE, DELETE, LIST and CREATE requests?


Solution

  • The mapping is explained in the router's documentation