默认情况下,DRF 视图集是否允许 PUT、PARTIAL_UPDATE、DELETE、CREATE、LIST 和 RETRIEVE?
By default, do DRF viewsets allow PUT, PARTIAL_UPDATE, DELETE, CREATE, LIST and RETRIEVE?
假设我创建了这个视图集:
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
lookup_field = 'username'
和这个路由器:
router.register(r'users', views.UserViewSet)
和这个序列化器:
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('username', 'password', 'email')
是否有文档提到默认情况下是否允许或不允许 user
接受 PUT
、PARTIAL_UPDATE
、DELETE
、LIST
和 CREATE
个请求?
中解释
假设我创建了这个视图集:
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
lookup_field = 'username'
和这个路由器:
router.register(r'users', views.UserViewSet)
和这个序列化器:
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('username', 'password', 'email')
是否有文档提到默认情况下是否允许或不允许 user
接受 PUT
、PARTIAL_UPDATE
、DELETE
、LIST
和 CREATE
个请求?