New Version of django does not support GET method for logout.

You have two options to accomplish your task:
1. Send a post  request to logout.
2. Custom Manage:
         > Create a custom url in the project's url.py at the top.
              path('admin/logout/', logout_),  
         > Create a view in the project's views.py.
              
def logout_(request):
logout(request)
return redirect('/admin/')

On Thursday, February 22, 2024 at 6:57:24 PM UTC+5:30 AshiQul Islam Munna 
wrote:

Hello!

I am using default auth system in my project these steps-

1. Add this in my project urls path("accounts/", include(
"django.contrib.auth.urls")), 

2. Create HTML file in  -'templates/registration/login.html'

3. In 'base.html' i wrote -
' {% if user.is_authenticated %}
        <p>Hi {{ user.username }}!</p>
        <p><a href="{% url 'logout' %}">Log out</a></p>
        {% else %}
        <p>You are not logged in.</p>
        <a href="{% url 'login' %}">Log In</a>
        {% endif %}
' 

4. And finally in 'setting.py' set 
LOGIN_REDIRECT_URL = "home"
LOGOUT_REDIRECT_URL = "home"

That's ALL!
' LOGIN ' works perfectly but "LOGOUT " not working. It say's-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/843cd8e9-97b3-4d37-8903-ddb8fcac00a1n%40googlegroups.com.

Reply via email to