Есть Django REST fraemwork.
Хочу чтоб при запросе:
/api/operations/?action=update&operation=7&date_operation=2018-04-01&operating_room=1&queue=null&is_reserve=true
Данные из url делали update в модели и сохраняли.
views.pyclass OperationsViewSet(viewsets.ModelViewSet):
serializer_class = OperationsSerializer
def get_queryset(self):
if self.request.query_params.get('start_period') and self.request.query_params.get(
'end_period') and self.request.query_params.get('is_reserve') and self.request.query_params.get(
'is_completed'):
if self.request.query_params.get('is_reserve') == 'true':
is_reserve = True
else:
is_reserve = False
if self.request.query_params.get('is_completed') == 'true':
is_completed = True
else:
is_completed = False
return Operation.objects.filter(date_operation__range=(
self.request.query_params.get('start_period'), self.request.query_params.get('end_period')),
is_reserve=is_reserve, is_completed=is_completed)
elif self.request.query_params.get('is_reserve') == 'true':
return Operation.objects.filter(is_reserve=True)
elif self.request.query_params.get('is_reserve') == 'false':
return Operation.objects.filter(is_reserve=False)
else:
return Operation.objects.all()