# Problem with auth\_views.LogoutView.as\_view method

**URL:** <https://forum.djangoproject.com/t/problem-with-auth-views-logoutview-as-view-method/30655>\
**Category:** Getting Started\
**Created:** [April 29, 2024, 6:03pm UTC](https://forum.djangoproject.com/t/problem-with-auth-views-logoutview-as-view-method/30655 "2024-04-29T18:03:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nam-hoang-le](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nam-hoang-le/32/20954_2.png) [@nam-hoang-le](https://forum.djangoproject.com/u/nam-hoang-le)\
**Post date:** [April 29, 2024, 6:03pm UTC](https://forum.djangoproject.com/t/problem-with-auth-views-logoutview-as-view-method/30655/1 "2024-04-29T18:03:19Z")

</div>

Hi, here is my running code:  
path(‘logout/’,auth\_views.LogoutView.as\_view(template\_name=“pages/logout.html”, next\_page=‘/’), name=‘logout’),

Here is my problem:  
Method Not Allowed (GET): /logout/  
Method Not Allowed: /logout/  
[30/Apr/2024 00:58:54] “GET /logout/ HTTP/1.1” 405 0

I already read some solutions avaiable, I tried to create a mini-form and link to that, but it wasn’t avaiable.

Here is my mini-form:  
logout.html

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

```

Please help me, thanks a lot!

---

<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:** [April 29, 2024, 7:18pm UTC](https://forum.djangoproject.com/t/problem-with-auth-views-logoutview-as-view-method/30655/2 "2024-04-29T19:18:49Z")

</div>

> [@nam-hoang-le](#):
>
> I tried to create a mini-form and link to that, but it wasn’t avaiable.

That form should be in the page containing your logout link, that’s not the logout template to be rendered by the logout view. (In other words wherever you have a link to “logout”, that’s where this form would be defined.)

---

<div class="post-metadata">

**Author:** ![nam-hoang-le](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nam-hoang-le/32/20954_2.png) [@nam-hoang-le](https://forum.djangoproject.com/u/nam-hoang-le)\
**Post date:** [April 30, 2024, 4:31am UTC](https://forum.djangoproject.com/t/problem-with-auth-views-logoutview-as-view-method/30655/3 "2024-04-30T04:31:00Z")

</div>

Hi, I don’t understand your answer, can you explain more clearly please ?

---

<div class="post-metadata">

**Author:** ![nam-hoang-le](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nam-hoang-le/32/20954_2.png) [@nam-hoang-le](https://forum.djangoproject.com/u/nam-hoang-le)\
**Post date:** [April 30, 2024, 4:33am UTC](https://forum.djangoproject.com/t/problem-with-auth-views-logoutview-as-view-method/30655/4 "2024-04-30T04:33:03Z")

</div>

So should I changed the template\_name variable to the normal path, the put the logout.html file in other path ?

---

<div class="post-metadata">

**Author:** ![nam-hoang-le](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nam-hoang-le/32/20954_2.png) [@nam-hoang-le](https://forum.djangoproject.com/u/nam-hoang-le)\
**Post date:** [April 30, 2024, 4:46am UTC](https://forum.djangoproject.com/t/problem-with-auth-views-logoutview-as-view-method/30655/5 "2024-04-30T04:46:38Z")

</div>

I actually found a way to fix the error:

```auto
path('logout/', LogoutView.as_view(next_page='register/', http_method_names = ['get', 'post', 'options']), name='logout'),

```

But now what I get is the Django administration logging out message going out, no matter how I changed the next\_page variable. Please show me how to fix this message

---

<div class="post-metadata">

**Author:** ![Dadduu2001](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dadduu2001/32/18693_2.png) [@Dadduu2001](https://forum.djangoproject.com/u/Dadduu2001)\
**Post date:** [April 30, 2024, 7:54am UTC](https://forum.djangoproject.com/t/problem-with-auth-views-logoutview-as-view-method/30655/6 "2024-04-30T07:54:16Z")

</div>

You have to put this mini-form in a page that contain your logout button… and don’t use template name only next\_page

---

<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:** [April 30, 2024, 11:17am UTC](https://forum.djangoproject.com/t/problem-with-auth-views-logoutview-as-view-method/30655/7 "2024-04-30T11:17:16Z")

</div>

That’s the wrong “fix”. You’ve just undone the security fix implemented by this change.

You have a `Logout` link on some page(s), that currently directs you to the `logout` url.

_That_ link is what gets replaced by the mini form.

For us to be more specific, we’d need to see the template containing the `Logout` link.
