aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorRob Romano2012-11-13 16:49:13 -0800
committerRob Romano2012-11-14 12:51:00 -0800
commit321ba156ca45da8a4b3328c4aec6a9235f32e5f8 (patch)
tree51bdbb438943c052cc4c7ef702e4b78cb721498a /rest_framework
parenteb20b5663e68ce01453eeb855922874001f42d0f (diff)
downloaddjango-rest-framework-321ba156ca45da8a4b3328c4aec6a9235f32e5f8.tar.bz2
Renamed AuthTokenView to ObtainAuthToken, added obtain_auth_token var, updated tests & docs. Left authtoken.urls in place as example.
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/authtoken/urls.py14
-rw-r--r--rest_framework/authtoken/views.py4
-rw-r--r--rest_framework/tests/authentication.py2
3 files changed, 11 insertions, 9 deletions
diff --git a/rest_framework/authtoken/urls.py b/rest_framework/authtoken/urls.py
index 87872136..a3419da6 100644
--- a/rest_framework/authtoken/urls.py
+++ b/rest_framework/authtoken/urls.py
@@ -1,20 +1,20 @@
"""
-Login and logout views for token authentication.
+Login view for token authentication.
-Add these to your root URLconf if you're using token authentication
+Add this to your root URLconf if you're using token authentication
your API requires authentication.
-The urls must be namespaced as 'rest_framework', and you should make sure
-your authentication settings include `TokenAuthentication`.
+You should make sure your authentication settings include
+`TokenAuthentication`.
urlpatterns = patterns('',
...
- url(r'^auth-token', include('rest_framework.authtoken.urls', namespace='rest_framework'))
+ url(r'^auth-token/', 'rest_framework.authtoken.obtain_auth_token')
)
"""
+
from django.conf.urls.defaults import patterns, url
-from rest_framework.authtoken.views import AuthTokenView
urlpatterns = patterns('rest_framework.authtoken.views',
- url(r'^login/$', AuthTokenView.as_view(), name='token_login'),
+ url(r'^login/$', 'rest_framework.authtoken.views.obtain_auth_token', name='token_login'),
)
diff --git a/rest_framework/authtoken/views.py b/rest_framework/authtoken/views.py
index e027dff1..3ac674e2 100644
--- a/rest_framework/authtoken/views.py
+++ b/rest_framework/authtoken/views.py
@@ -6,7 +6,7 @@ from rest_framework.response import Response
from rest_framework.authtoken.models import Token
from rest_framework.authtoken.serializers import AuthTokenSerializer
-class AuthTokenView(APIView):
+class ObtainAuthToken(APIView):
throttle_classes = ()
permission_classes = ()
parser_classes = (parsers.FormParser, parsers.MultiPartParser, parsers.JSONParser,)
@@ -20,3 +20,5 @@ class AuthTokenView(APIView):
return Response({'token': token.key})
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
+
+obtain_auth_token = ObtainAuthToken.as_view()
diff --git a/rest_framework/tests/authentication.py b/rest_framework/tests/authentication.py
index cb16ef1e..96ca9f52 100644
--- a/rest_framework/tests/authentication.py
+++ b/rest_framework/tests/authentication.py
@@ -27,7 +27,7 @@ MockView.authentication_classes += (TokenAuthentication,)
urlpatterns = patterns('',
(r'^$', MockView.as_view()),
- (r'^auth-token/', include('rest_framework.authtoken.urls')),
+ (r'^auth-token/', 'rest_framework.authtoken.views.obtain_auth_token'),
)