22 lines
558 B
Python
22 lines
558 B
Python
|
from rest_framework import routers, viewsets, serializers
|
||
|
from django.contrib.auth.models import User
|
||
|
|
||
|
|
||
|
class UserSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = User
|
||
|
fields = ('id', 'username', 'email', 'first_name', 'last_name')
|
||
|
|
||
|
|
||
|
class UserViewSet(viewsets.ModelViewSet):
|
||
|
queryset = User.objects.all()
|
||
|
serializer_class = UserSerializer
|
||
|
authentication_classes = []
|
||
|
permission_classes = []
|
||
|
|
||
|
|
||
|
router = routers.SimpleRouter()
|
||
|
router.register(r'users', UserViewSet, basename='users')
|
||
|
|
||
|
urlpatterns = router.urls
|