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") ]