Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

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

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda