0
votes

Views.py

def logoutUser(request):
    logout(request)
    return HttpResponseRedirect('login')

urls.py

 path('login/',views.Login,name='login'),
 path('logout/',views.logout,name='logout'),

Html

{% if user.is_authenticated %}
<li class="nav-item">
   <a  class="nav-link" href="{% url 'logout' %}">Logout</a>         </li>

The view django.contrib.auth.logout didn't return an HttpResponse object. It returned None instead.

Exception Location: C:\Users\dheeraj\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py in _get_response, line 124

I also tried it using render and change url format ,but unable to understand where i am doing mistake.

1
Thankyou , i understand where i do mistake.Py_Patience

1 Answers

0
votes

I have solved it. just small changes in url.py

path(r'^logout/',views.logout,name='logout'),