from django.conf.urls import url, include
from django.contrib.auth.models import User
from rest_framework import routers, serializers, viewsets
# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
# 定义了我们序列化的模型和显示的字段, url为网络接口
fields = ('url', 'username', 'email', 'is_staff')
class UserViewSet(viewsets.ModelViewSet):
# 查询对象集
queryset = User.objects.all()
# 序列化的类名
serializer_class = UserSerializer
# 固定写法!不能改名字!