Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

0

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

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda