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

144
Views
Prevent Django from logout through url before hitting enter

So I have created a Django-app with a login form and using login(request, user) in my view.py to login the user. This is the main page and has the location mypage.com. I also created another function in my view.py called log_out:

def log_out(request):
    logout(request)
    return redirect('/') 

This function is used to log out a user using the url: mysite.com/logout as defined in my url.py:

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

This is working to log out the user, however the user is being logged out as I'm typing in the logout-url into the address-field of my browser, and before hitting enter to go to that endpoint.

I would like it to not log out the user when typing in the url, and wait until I'm "entering" the site.

Can anyone help me with this one?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

What i am doing is redirecting the user to my login page.So I should say you should try this.My application only logouts after I hit the enter button.

url:-

app_name = 'name'
url(r'^logout$', user.logout_user, name='logout_user'),
 url(r'^$', user.login_user, name='login'),

views:-

def logout_user(request):
    logout(request)
    return redirect('name:login')
over 4 years ago · Santiago Trujillo Report

0

I ended up using a POST-method as suggested by @danihp.

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!