API дополнена query params
This commit is contained in:
1 parent
5c7e3d5e2e
commit
5b8c627033
2 files changed
+3
-2
No files matched your search
@@ -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
@@ -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 = []
|
||||
|
||||
Reference in new issue
Block a user