Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

388
Views
Django logout ValueError

I have a ValueError at logout in Django. It says: The view django.contrib.auth.logout didn't return an HttpResponse object. It returned None instead.

My code is extremely short:

def logout_view(request):
    logout(request)
    return HttpResponseRedirect('/some_page/')

I tried with shortcut redirect as well. Probably I misunderstand how this works.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Use this code. Works perfectly fine for me.

from django.core.urlresolvers import reverse
from django.contrib.auth import login, logout , authenticate

def accounts_logout(request):
    logout(request)
    url = reverse("accounts:login")
    return redirect(url, args=(),kwargs={}) 

in your url pattern there should be an URL:

url(r'^accounts-login/$', views.accounts_login, name='login'),
over 4 years ago · Santiago Trujillo Report

0

Try this.

return render_to_response('logout.html', {'request': request})
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!