【发布时间】:2019-09-25 14:43:26
【问题描述】:
我有这个 ModelViewSet 类:
class DriveInvoiceViewSet(viewsets.ModelViewSet):
filter_fields = ('location_id', 'logical_deleted')
permission_classes = (UserCanManageFacilityPermission,)
pagination_class = None
def get_serializer_class(self):
...
def get_queryset(self):
...
@action(detail=False, methods=['GET'])
def get_subtotals_by_unit(self, request):
invoices_list = self.filter_queryset(self.get_queryset())
grouped_invoices = get_subtotals_by_unit(invoices_list)
return Response(grouped_invoices)
如何从反向函数获取 URL 以测试 get_subtotals_by_unit 操作?
路由器注册的ViewSetrouter.register('drive_invoices', DriveInvoiceViewSet, base_name='drive_invoices')
【问题讨论】:
标签: python django testing django-rest-framework