From 8bb12212e5289a42737a29dc29a085e2c609baf0 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Mon, 9 Mar 2015 22:26:41 -0400 Subject: [PATCH] Move around the user view set into its own file. --- roadmap/urls.py | 25 +++++-------------------- roadmap/user_api_views.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 roadmap/user_api_views.py diff --git a/roadmap/urls.py b/roadmap/urls.py index 931714a..c39100b 100644 --- a/roadmap/urls.py +++ b/roadmap/urls.py @@ -1,28 +1,13 @@ from django.conf.urls import patterns, include, url -from django.contrib.auth.models import User from django.contrib import admin -from rest_framework import routers, serializers, viewsets +from rest_framework import routers +from user_api_views import UserViewSet -# Serializers define the API representation. -class UserSerializer(serializers.HyperlinkedModelSerializer): - class Meta: - model = User - fields = ('url', 'username', 'email', 'is_staff') - -# ViewSets define the view behavior. -class UserViewSet(viewsets.ModelViewSet): - queryset = User.objects.all() - serializer_class = UserSerializer - -# Routers provide an easy way of automatically determining the URL conf. router = routers.DefaultRouter() router.register(r'users', UserViewSet) - - - urlpatterns = patterns('', - url(r'^admin/', include(admin.site.urls)), - url(r'^api/', include(router.urls)), - url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) + url(r'^admin/', include(admin.site.urls)), + url(r'^api/', include(router.urls)), + url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) ) diff --git a/roadmap/user_api_views.py b/roadmap/user_api_views.py new file mode 100644 index 0000000..f42494b --- /dev/null +++ b/roadmap/user_api_views.py @@ -0,0 +1,15 @@ +__author__ = 'tyrel' +from rest_framework import serializers, viewsets +from django.contrib.auth.models import User + + +# Serializers define the API representation. +class UserSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = User + fields = ('url', 'username', 'email', 'is_staff') + +# ViewSets define the view behavior. +class UserViewSet(viewsets.ModelViewSet): + queryset = User.objects.all() + serializer_class = UserSerializer \ No newline at end of file