what is rest framework code example
Example 1: what is a REST API
An endpoint is one end of a communication channel.
it would be represented as the URL of a server or service.
In REST APIs, the resource typically refers to some object or set of objects
that are exposed at an API endpoint.
An endpoint by itself is just
a reference to a URL that accepts web requests that may or may not be RESTful.
Example 2: restfull api in django
from django.contrib.auth.models import User, Group
from rest_framework import viewsets
from rest_framework import permissions
from tutorial.quickstart.serializers import UserSerializer, GroupSerializer
class UserViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = User.objects.all().order_by('-date_joined')
serializer_class = UserSerializer
permission_classes = [permissions.IsAuthenticated]
class GroupViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows groups to be viewed or edited.
"""
queryset = Group.objects.all()
serializer_class = GroupSerializer
permission_classes = [permissions.IsAuthenticated]