Skip to content
Snippets Groups Projects
Commit 245b41b3 authored by Fabien  MAREUIL's avatar Fabien MAREUIL
Browse files

api search by code

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