Django Rest Api Framework Without Models
I created a simple html page which allows me to upload an image and store it in the directory without the use of a model. My aim is to use the REST API framework and display that p
Solution 1:
Use ViewSets and override it's get and post methods
https://www.django-rest-framework.org/api-guide/viewsets/
in the urls.py provide this SomeViewSet.as_view({'get': 'list', 'post':'create'})
where get and posts refers to the GET and POST methods, while list and create refers to the functions in your ViewSet
You don't have to mention models anywhere.
In the end you can have something like this return JsonResponse({"image": "uploaded_image_by_user"})
JsonResponse as from django.http import JsonResponse
Post a Comment for "Django Rest Api Framework Without Models"