From b97b34961c9fe18c21a2787fd7f5e35454371a4f Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 24 Aug 2016 12:29:19 +0800 Subject: [PATCH] Modify api: complete some setting --- apps/users/api_urls.py | 7 +------ apps/users/serializers.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/users/api_urls.py b/apps/users/api_urls.py index 40a1ff414..021204305 100644 --- a/apps/users/api_urls.py +++ b/apps/users/api_urls.py @@ -2,14 +2,9 @@ # from django.conf.urls import url, include -from rest_framework import routers from .api import UserViewSet -router = routers.DefaultRouter() -router.register(r'users', UserViewSet) - urlpatterns = [ - url(r'v1/', include(router.urls)), - url(r'^api-auth/', include('rest_framework.urls', namespace='rest_fr \ No newline at end of file +] diff --git a/apps/users/serializers.py b/apps/users/serializers.py index e08b52b47..c087cc3d2 100644 --- a/apps/users/serializers.py +++ b/apps/users/serializers.py @@ -6,7 +6,19 @@ from rest_framework import serializers from .models import Role, User, UserGroup -class UserSerializer(serializers.HyperlinkedModelSerializer): +class UserSerializer(serializers.ModelSerializer): class Meta: model = User - fields = \ No newline at end of file + exclude = ['first_name', 'last_name', 'is_staff'] + + +class UserGroupSerializer(serializers.ModelSerializer): + class Meta: + model = UserGroup + fields = '__all__' + + +class RoleSerializer(serializers.ModelSerializer): + class Meta: + model = Role + fields = '__all__'