I am using django-rest-framework for api for my webapp. Is it good to use django rest framework instead of default ORM provided by django ? I referenced this post and am still confused. Since drf-api requires the creation of classes, and I think it is better to use this code to process objects, since I can reuse the code.
urls.py
router = routers.DefaultRouter() router.register(r'users', views.UserViewSet)
views.py
class UserViewSet(viewsets.ModelViewSet): """ API endpoint that allows users to be viewed or edited. """ queryset = User.objects.all() serializer_class = UserSerializer
serializers.py
class UserSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = User fields = ('url', 'username', 'email', 'groups')
How can I handle objects with the crud method in views.py using the django rest framework?
rest api django django-rest-framework
cutteeth
source share