From b769f5a88585314cb7e519e4dcb40deab4347b4f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 3 Apr 2021 15:54:59 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Configure=20Django=20REST=20fram?= =?UTF-8?q?ework?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sophon/settings.py | 13 +++++++++++++ sophon/urls.py | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sophon/settings.py b/sophon/settings.py index 41c3167..79e0d86 100644 --- a/sophon/settings.py +++ b/sophon/settings.py @@ -38,6 +38,7 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'rest_framework', ] MIDDLEWARE = [ @@ -119,3 +120,15 @@ USE_TZ = True # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = '/static/' + + +# Django REST framework +# https://www.django-rest-framework.org/#example + +REST_FRAMEWORK = { + # Use Django's standard `django.contrib.auth` permissions, + # or allow read-only access for unauthenticated users. + 'DEFAULT_PERMISSION_CLASSES': [ + 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' + ] +} diff --git a/sophon/urls.py b/sophon/urls.py index cb22004..2b29f9e 100644 --- a/sophon/urls.py +++ b/sophon/urls.py @@ -14,8 +14,9 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), + path('api-auth/', include("rest_framework.urls"), namespace="rest_framework") ]