Move around the user view set into its own file.
This commit is contained in:
parent
6c6b0225a5
commit
8bb12212e5
@ -1,26 +1,11 @@
|
|||||||
from django.conf.urls import patterns, include, url
|
from django.conf.urls import patterns, include, url
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.contrib import admin
|
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 = routers.DefaultRouter()
|
||||||
router.register(r'users', UserViewSet)
|
router.register(r'users', UserViewSet)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
url(r'^api/', include(router.urls)),
|
url(r'^api/', include(router.urls)),
|
||||||
|
15
roadmap/user_api_views.py
Normal file
15
roadmap/user_api_views.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user