Reputation: 2122
I am getting error while updating. When i add data it is added successfully. This error is only comming for UpdateAPIView
{
"detail": "Method \"POST\" not allowed."
}
urls.py
path('groups/update/<int:pk>', views.GroupsUpdateAPIView.as_view(), name='api_groups_update'),
Views.py
class GroupsUpdateAPIView(generics.UpdateAPIView):
queryset = Groups.objects.all()
serializer_class = GroupsAddSerialzer
permission_classes = [UserIsAuthenticated]
def perform_update(self, serializer):
serializer.save(
group_updated_by = self.request.auth.application.user,
)
Serializer.py
class GroupsAddSerialzer(serializers.ModelSerializer):
class Meta:
model = Groups
fields = ['group_name', 'group_description', 'group_status']
Upvotes: 1
Views: 1668
Reputation: 472
The UpdateAPIView
view uses the HTTP methods PUT
and PATCH
. The method POST
is used to create a new instance with CreateAPIView
view.
Upvotes: 5