# Deprecation of GET method for LogoutView

**URL:** <https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533>\
**Category:** Forms & APIs\
**Created:** [November 21, 2023, 8:23pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533 "2023-11-21T20:23:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhino](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/rhino/32/16958_2.png) [@rhino](https://forum.djangoproject.com/u/rhino)\
**Post date:** [November 21, 2023, 8:23pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/1 "2023-11-21T20:23:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 21, 2023, 9:07pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/2 "2023-11-21T21:07:13Z")

</div>

The short answer is that it’s basically “un safe” for the user.

The Django developers mailing list has a couple of threads as to why this was considered appropriate.

- [https://code.djangoproject.com/ticket/15619](https://code.djangoproject.com/ticket/15619)
- [https://groups.google.com/g/django-developers/c/1FMzLzfZkeE/m/cqlvmndPAgAJ](https://groups.google.com/g/django-developers/c/1FMzLzfZkeE/m/cqlvmndPAgAJ)
- [https://groups.google.com/g/django-developers/c/ax95u\_f82D4](https://groups.google.com/g/django-developers/c/ax95u_f82D4)

---

<div class="post-metadata">

**Author:** ![kemoNjie](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kemonjie/32/13312_2.png) [@kemoNjie](https://forum.djangoproject.com/u/kemoNjie)\
**Post date:** [January 5, 2024, 5:20pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/3 "2024-01-05T17:20:20Z")

</div>

Am new to Django currently having this issue, my logout is always returning “GET /accounts/logout/ HTTP/1.1” 405 0, and am using CBV

---

<div class="post-metadata">

**Author:** ![kemoNjie](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kemonjie/32/13312_2.png) [@kemoNjie](https://forum.djangoproject.com/u/kemoNjie)\
**Post date:** [January 5, 2024, 5:33pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/4 "2024-01-05T17:33:58Z")

</div>

```auto
<form method="post" action="{% url 'logout' %}">
    {% csrf_token %}
    <button type="submit">logout</button>
</form>

```

This work for me but i need to customize the template for the logout user who is not an admin

---

<div class="post-metadata">

**Author:** ![kemoNjie](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kemonjie/32/13312_2.png) [@kemoNjie](https://forum.djangoproject.com/u/kemoNjie)\
**Post date:** [January 5, 2024, 5:34pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/5 "2024-01-05T17:34:29Z")

</div>

```auto
<form method="post" action="{% url 'logout' %}">
    {% csrf_token %}
    <button type="submit">logout</button>
</form>

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 5, 2024, 9:18pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/6 "2024-01-05T21:18:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![vesi-velkova](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/vesi-velkova/32/19055_2.png) [@vesi-velkova](https://forum.djangoproject.com/u/vesi-velkova)\
**Post date:** [February 8, 2024, 9:13pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/7 "2024-02-08T21:13:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Aboubakar](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/aboubakar/32/19299_2.png) [@Aboubakar](https://forum.djangoproject.com/u/Aboubakar)\
**Post date:** [February 19, 2024, 2:56pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/8 "2024-02-19T14:56:23Z")

</div>

Hello i have the same problem do you found a solution?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 19, 2024, 3:47pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/9 "2024-02-19T15:47:42Z")

</div>

The answer is at [Deprecation of GET method for LogoutView - #5 by kemoNjie](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/5), which is the same answer as in the other thread here that you found.

---

<div class="post-metadata">

**Author:** ![Aboubakar](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/aboubakar/32/19299_2.png) [@Aboubakar](https://forum.djangoproject.com/u/Aboubakar)\
**Post date:** [February 19, 2024, 3:58pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/10 "2024-02-19T15:58:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shivamalk-23](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/shivamalk-23/32/19436_2.png) [@shivamalk-23](https://forum.djangoproject.com/u/shivamalk-23)\
**Post date:** [February 26, 2024, 12:27pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/11 "2024-02-26T12:27:17Z")

</div>

hey iam also new to django  
my solution is try using the button enclosed by form with POST method and use csrf token

````auto

<form method="post" action="{% url 'logout' %}">
    {% csrf_token %}
    <button type="submit">logout</button>
</form>

{% else %}

<a href="{% url 'login' %}">login</a>
{% endif %}
     ```
````

---

<div class="post-metadata">

**Author:** ![prudviraj939](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/prudviraj939/32/19449_2.png) [@prudviraj939](https://forum.djangoproject.com/u/prudviraj939)\
**Post date:** [February 27, 2024, 12:00pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/12 "2024-02-27T12:00:33Z")

</div>

Hi @shivamalk-23,

The code you have mentioned is not working for me, I am getting the same error.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/7/b/7b45be4e83370c1b75de95b954dae0a6a19154fb.png)

Pls help me with this,

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 27, 2024, 12:12pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/13 "2024-02-27T12:12:17Z")

</div>

Welcome @prudviraj939 !

You’re going to need to be a lot more specific here.

When & how are you using this? What are you doing (specifically) when the error is being thrown? What is the exact error being received?

---

<div class="post-metadata">

**Author:** ![prudviraj939](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/prudviraj939/32/19449_2.png) [@prudviraj939](https://forum.djangoproject.com/u/prudviraj939)\
**Post date:** [February 27, 2024, 5:17pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/14 "2024-02-27T17:17:27Z")

</div>

Hi @KenWhitesell,

Thanks for the reply

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

pls help me through this?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 27, 2024, 5:20pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/15 "2024-02-27T17:20:19Z")

</div>

You cannot go directly to `/admin/logout/` as a url using a get.

You post:

> [@prudviraj939](#):
>
> When I am tryig to access logout endpoint, I am getting this error  
> Method Not Allowed (GET): /admin/logout/  
> Method Not Allowed: /admin/logout/  
> [27/Feb/2024 17:50:35] “GET /admin/logout/ HTTP/1.1” 405 0

How are you trying to access this? What link are you clicking on a page to do this?

---

<div class="post-metadata">

**Author:** ![prudviraj939](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/prudviraj939/32/19449_2.png) [@prudviraj939](https://forum.djangoproject.com/u/prudviraj939)\
**Post date:** [February 27, 2024, 6:11pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/16 "2024-02-27T18:11:10Z")

</div>

Hi @KenWhitesell,

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.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 27, 2024, 6:13pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/17 "2024-02-27T18:13:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![prudviraj939](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/prudviraj939/32/19449_2.png) [@prudviraj939](https://forum.djangoproject.com/u/prudviraj939)\
**Post date:** [February 27, 2024, 6:15pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/18 "2024-02-27T18:15:57Z")

</div>

This is the HTML I am using for logout.html,

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/e/4/e4bb06008398daed44d411489b0ca5863e7710c7.png)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 27, 2024, 6:17pm UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/19 "2024-02-27T18:17:52Z")

</div>

So you’re saying that you’re clicking on this button, and that is creating the error that you’re seeing?

It would be a lot more helpful to see the rendered HTML as it exists in the browser for the page containing the link being clicked.

---

<div class="post-metadata">

**Author:** ![prudviraj939](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/prudviraj939/32/19449_2.png) [@prudviraj939](https://forum.djangoproject.com/u/prudviraj939)\
**Post date:** [February 28, 2024, 4:06am UTC](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533/20 "2024-02-28T04:06:53Z")

</div>

This is the HTML that have been rendered, I have already posted template I am using and view I have built using it

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/0/2/0209157ad426b6de143266ddc2ae1d0e9ab3944c.png)

[Next page](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533.md?page=2)
