what is the django rest framework code example
Example 1: install django rest framework
pip install djangorestframework
Example 2: django rest framework
pip install djangorestframework
pip install markdown
pip install django-filter
Example 3: django rest framework
$ pipenv install djangorestframework
pip install djangorestframework
Example 4: djangorestframework
from django.conf.urls import url, include
from django.contrib.auth.models import User
from rest_framework import routers, serializers, viewsets
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ['url', 'username', 'email', 'is_staff']
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
router = routers.DefaultRouter()
router.register(r'users', UserViewSet)
urlpatterns = [
url(r'^', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
]