Enable browsable API login

This commit is contained in:
Tanner Collin 2020-01-06 23:05:19 +00:00
parent 095003b943
commit c5b0a93927
2 changed files with 12 additions and 0 deletions

View File

@ -47,6 +47,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'apiserver.api',
]
@ -139,10 +140,20 @@ if DEBUG:
'rest_framework.renderers.BrowsableAPIRenderer',
)
DEFAULT_AUTHENTICATION_CLASSES = (
'rest_framework.authentication.TokenAuthentication',
)
if DEBUG:
DEFAULT_AUTHENTICATION_CLASSES += (
'rest_framework.authentication.SessionAuthentication',
)
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 20,
'DEFAULT_RENDERER_CLASSES': DEFAULT_RENDERER_CLASSES,
'DEFAULT_AUTHENTICATION_CLASSES': DEFAULT_AUTHENTICATION_CLASSES,
}
LOGGING = {

View File

@ -10,4 +10,5 @@ router.register(r'users', views.UserViewSet)
urlpatterns = [
path('', include(router.urls)),
path('admin/', admin.site.urls),
path('api-auth/', include('rest_framework.urls')),
]