DRF to delete multiple records with field other than ID

Asked

Viewed 18 times

-1

I am using the Django Rest Framework and would like to make a mass exclusion using the "contract" field which is an interger.

View py.

class AlugueisViewSet(viewsets.ModelViewSet):

   filter_backends = (filters.SearchFilter,DjangoFilterBackend)
   queryset = Alugueis.objects.all()
   serializer_class = AlugueisSerializer    
   filterset_fields = {           
        'contrato':['exact']            
   }

Send

Request URL: http://127.0.0.1:8000/rentals/? id=&contract=174

Request Method: DELETE

Status Code: 405 Method Not Allowed

Remote Address: 127.0.0.1:8000

Referrer Policy: Strict-origin-when-cross-origin

  • Since you are using viewset, we still need to implement the Destroy function.

  • could put an example?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.