Created
February 14, 2020 15:57
-
-
Save ntoll/5161942a5e6f08afc10dda14712e4f2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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")), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment