Explore Courses Blog Tutorials Interview Questions
0 votes
in Web Technology by (19.9k points)

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


urlpatterns = [

path('', include('RunKeeper.urls')),

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


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 Answer

0 votes
by (25.1k points)

Add BasicAuthentication and SessionAuthentication classes in DEFAULT_AUTHENTICATION_CLASSES class as below.







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.

Related questions

0 votes
1 answer
asked Mar 8, 2021 in Web Technology by Rekha (2.2k points)
0 votes
1 answer
0 votes
0 answers
0 votes
1 answer

Browse Categories