Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Exception Type: ProtectedError at /api/v1/spi/sites/6
- Exception Value: ("Cannot delete some instances of model 'Site' because they are referenced through a protected foreign key: 'Location.site'", <QuerySet [<Location: a_location>]>)
- class LocationDetail(generics.RetrieveUpdateDestroyAPIView):
- # using get_queryset().order_by('id') prevents UnorderedObjectListWarning
- queryset = Location.objects.order_by('id')
- serializer_class = LocationSerializer
- permission_classes = (SPIPermission,)
- def perform_destroy(self, instance):
- print('LocationDetail destroy() called.')
- location = self.get_object().location
- try:
- location.delete()
- except Exception as ex:
- print(ex)
- return Response({"message": "%s." % ex}, status=status.HTTP_400_BAD_REQUEST)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement