Commit 245b41b3 authored by Fabien  MAREUIL's avatar Fabien MAREUIL
Browse files

api search by code

parent 5c14f1c3
Pipeline #56531 passed with stages
in 22 minutes and 52 seconds
...@@ -22,8 +22,11 @@ class PdbViewSet(viewsets.ModelViewSet): ...@@ -22,8 +22,11 @@ class PdbViewSet(viewsets.ModelViewSet):
@action(detail=True, methods=["get"]) @action(detail=True, methods=["get"])
def get_queryset(self): def get_queryset(self):
code = self.request.GET.get("code")
if "pk" in self.kwargs: if "pk" in self.kwargs:
queryset = PDB.objects.filter(pk=self.kwargs["pk"]) queryset = PDB.objects.filter(pk=self.kwargs["pk"])
elif code:
queryset = PDB.objects.filter(code=code)
else: else:
queryset = PDB.objects.all().values("code", "id") queryset = PDB.objects.all().values("code", "id")
return queryset return queryset
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment