diff --git a/django_rest/settings/settings.py b/django_rest/settings/settings.py index 4bbc520227ab5f86ae66e517bcc1c42b4b1b881a..78a9a871d0b51ed05b6a8600dfe7ce1c231ee265 100644 --- a/django_rest/settings/settings.py +++ b/django_rest/settings/settings.py @@ -45,6 +45,7 @@ INSTALLED_APPS = [ # Django REST Package. 'rest_framework', + 'rest_framework.authtoken', # Built-in Django apps. 'django.contrib.admin', diff --git a/django_rest/test_app/routes.py b/django_rest/test_app/routes.py index 1684c39b7475e46e79bbf4fa6af740f70794ebcd..8f24ea43a4f87ba2ce4668bb7c2b97789e3264aa 100644 --- a/django_rest/test_app/routes.py +++ b/django_rest/test_app/routes.py @@ -9,12 +9,11 @@ Urls for Django REST test project app. from rest_framework import routers # Internal Imports. +from test_app import views -from test_app import views router = routers.DefaultRouter() -# Hyperlink API Views. # Model API Views. router.register(r'users', views.UserModelViewSet) diff --git a/django_rest/test_app/templates/test_app/index.html b/django_rest/test_app/templates/test_app/index.html index 782eb48c6d18325b5236528e296f21a3e2eb4ecb..28dadb391a5dda6f34f48cea4e3bc24f2ac565c5 100644 --- a/django_rest/test_app/templates/test_app/index.html +++ b/django_rest/test_app/templates/test_app/index.html @@ -44,5 +44,16 @@ </li> </ul> </li> + <li> + <p>Django REST API Views</p> + <ul> + <li> + <p><a href="">Django REST Endpoints</a> - TODO: Url not yet set.</p> + </li> + <li> + <p><a href="{% url 'test_app:api_token_auth' %}">Generate User Auth Token</a></p> + </li> + </ul> + </li> </ul> {% endblock content %} diff --git a/django_rest/test_app/urls.py b/django_rest/test_app/urls.py index 4ac5e8febcd155cc1d9cd91ce3835501c1f730dc..71407c25b6a367c9c9e8ceb055d70d71a242cf9d 100644 --- a/django_rest/test_app/urls.py +++ b/django_rest/test_app/urls.py @@ -4,6 +4,7 @@ Urls for Django REST test project app. # Third-Party Imports. from django.urls import path +from rest_framework.authtoken import views as rest_views # Internal Imports. from . import views @@ -21,6 +22,9 @@ urlpatterns = [ path('api/display/', views.api_display, name='api_display'), path('api/send/', views.api_send, name='api_send'), + # Test REST API views. + path('api/api-token-auth', rest_views.obtain_auth_token, name='api_token_auth'), + # App root. path('', views.index, name='index') ]