API дополнена query params

This commit is contained in:
Alex committed 2024-02-02 09:43:51 +03:00
1 parent 5c7e3d5e2e
commit 5b8c627033
2 files changed
+3 -2

No files matched your search

+1 -1
View File
@@ -81,7 +81,7 @@ const burl = baseURL.slice(0,-1)
onBeforeMount(() => {
axiosApiInstance.get(`api/safety/files/`).then(result => {
axiosApiInstance.get(`api/safety/files/?chapter_id=fire_safety`).then(result => {
safetyData.value = result.data
})
});
+2 -1
View File
@@ -10,7 +10,8 @@ from .models import *
class SafetyFileAPIView(APIView):
def get(self, request):
all_file = SafetyFile.objects.order_by('chapter_id', 'category_id').all()
chapters = self.request.query_params.get('chapter_id', 1)
all_file = SafetyFile.objects.filter(chapter_id=chapters).order_by('chapter_id', 'category_id').all()
serializer_for_file = SafetyFileSerializer(instance=all_file, many=True)
data = []