0
votes

It should display the Django REST framework login page when i press the login button in the browsable api, but it doesn't. i got this HTTP response : "GET /api-auth/login/?next=/api-auth/login/ HTTP/1.1" 200 5415

Base URLs.py:

urlpatterns = [

path('', include('RunKeeper.urls')),
path('api-auth/', include('rest_framework.urls')),]

rest-framework URLs.py:

from __future__ import unicode_literals

from django.conf.urls import url
from django.contrib.auth import views

template_name = {'template_name': 'rest_framework/login.html'}

app_name = 'rest_framework'
urlpatterns = [
    url(r'^login/$', views.LoginView.as_view(), template_name, name='login'),
    url(r'^logout/$', views.LogoutView.as_view(), template_name, name='logout'),

I've included the rest-framework in the installed apps.

How can i solve the problem

1

1 Answers

0
votes

Add BasicAuthentication and SessionAuthentication classes in DEFAULT_AUTHENTICATION_CLASSES class as below.

 REST_FRAMEWORK = {
        'DEFAULT_AUTHENTICATION_CLASSES': (
            'rest_framework.authentication.BasicAuthentication',
            'rest_framework.authentication.SessionAuthentication',
        )
    }

And url patterns as below

urlpatterns = [
    url(r'^login/$', views.LoginView.as_view(template_name='rest_framework/login.html'), name='login'),
    url(r'^logout/$', views.LogoutView.as_view(), name='logout'),
]

Why you have login template in logoutView? Remove that one as well.