From 3820b4d45770890fbfda46792431c5c75a687a8e Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Wed, 6 Mar 2024 09:02:35 -0500 Subject: [PATCH] Start of progress with determining how REST authentication works --- django_rest/settings/settings.py | 1 + django_rest/test_app/routes.py | 3 +-- django_rest/test_app/templates/test_app/index.html | 11 +++++++++++ django_rest/test_app/urls.py | 4 ++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/django_rest/settings/settings.py b/django_rest/settings/settings.py index 4bbc520..78a9a87 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 1684c39..8f24ea4 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 782eb48..28dadb3 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 4ac5e8f..71407c2 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') ] -- GitLab