I was just wondering why the logout is not working after updating Django and have seen that using GET method is deprecated while using django.contrib.auth.views.LogoutView. What’s the point behind the decision to deprecate GET method?
Maybe someone can enlighten me to understand why I cannot use a simple logout via <a href> in combination with the default LogoutView because it feels like I’m missing something really important why POST is much better than GET in this case.
Side note: When you’re posting code or templates here, you need to surround the text between lines of three backtick - ` characters. This means you’ll have a line of ```, then the code (or template), then another line of ```. (I’ve taken the liberty of modifying your posts for this, please remember to do this in the future.)
So you know what it is you need to do - what is it that you have questions about?
Hi! I put the same form in templates, but still I see the same issue. Can you give me more information about all of the steps that you executed connected to the Log out?
Ok I see, but with the default authentication system there is no need to write views or URLs right all I have to do is write the templates but in this case how knowing that normally I am supposed to enter the hard URL in the browser to log out the user . In this case, how to make sure to display the suggested logout form in the solution
I am trying to create a Logout view using the below code,
from django.contrib.auth.views import LoginView, LogoutView
class LogoutInterfaceView(LogoutView):
template_name = ‘home/logout.html’
and I have also added url path in urls.py in the app home,
path(‘login’, views.LoginInterfaceView.as_view(), name=“login”),
path(‘logout’, views.LogoutInterfaceView.as_view(), name=“logout”)
]
When I am tryig to access logout endpoint, I am getting this error
Method Not Allowed (GET): /logout
Method Not Allowed: /logout
[27/Feb/2024 17:26:06] “GET /logout HTTP/1.1” 405 0
Sorry for the wrong output I have posted. I have changed it over there. I have tried various suggestions mentioned in this thread. Nothing is working. Pls help me through this.
You still need to specifically identify what it is that you are doing that is creating that output. If you’re clicking a link on a page, you need to show the html from the page containing that link. If you’re doing something else to send a request to that URL, you need to show what you’re doing.