# cannot logout through DRF

**URL:** <https://forum.djangoproject.com/t/cannot-logout-through-drf/28277>\
**Category:** Forms & APIs\
**Created:** [February 20, 2024, 9:12pm UTC](https://forum.djangoproject.com/t/cannot-logout-through-drf/28277 "2024-02-20T21:12:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![petrukv](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/petrukv/32/19331_2.png) [@petrukv](https://forum.djangoproject.com/u/petrukv)\
**Post date:** [February 20, 2024, 9:12pm UTC](https://forum.djangoproject.com/t/cannot-logout-through-drf/28277/1 "2024-02-20T21:12:35Z")

</div>

is says that [20/Feb/2024 22:59:10] “GET /accounts/logout/ HTTP/1.1” 405 0

in drf by link [http://127.0.0.1:8000/api/v1/](http://127.0.0.1:8000/api/v1/) i click on registered user → logout and it throw an error  
also if i try to visit [http://127.0.0.1:8000/accounts/logout/](http://127.0.0.1:8000/accounts/logout/) it has the same error

questionTime/urls.py

```auto
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.contrib.auth.views import LogoutView
from django.urls import include, path, re_path
from django_registration.backends.one_step.views import RegistrationView

from core.views import IndexTemplateView
from users.forms import CustomUserForm

urlpatterns = [
    path('admin/', admin.site.urls),
    path(
        "accounts/register/", RegistrationView.as_view(form_class=CustomUserForm, success_url="/",),
                                                        name="django_registration_register",),
    path("accounts/", include("django.contrib.auth.urls")),
    path("api-auth/", include("rest_framework.urls")),
    path('auth/', include('djoser.urls')),
    path('auth/', include('djoser.urls.authtoken')),
    path("api/v1/", include("questions.api.urls")),
    path("api-auth/logout/", LogoutView.as_view(), name="rest_logout"),
    re_path(r"^.*$", IndexTemplateView.as_view(), name="entry-point"),
]

```

core/views.py

```auto
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic.base import TemplateView

class IndexTemplateView(LoginRequiredMixin, TemplateView):

    template_name = "index.html"

```

users/forms.py

> from django\_registration.forms import RegistrationForm
> 
> from users.models import CustomUser
> 
> class CustomUserForm(RegistrationForm):  
> class Meta(RegistrationForm.Meta):  
> model = CustomUser

---

<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 20, 2024, 9:25pm UTC](https://forum.djangoproject.com/t/cannot-logout-through-drf/28277/2 "2024-02-20T21:25:28Z")

</div>

See the threads (and the related links) at:

- [Showing `Method Not Allowed (GET): /users/logout/`](https://forum.djangoproject.com/t/showing-method-not-allowed-get-users-logout/26044)
- [Deprecation of GET method for LogoutView](https://forum.djangoproject.com/t/deprecation-of-get-method-for-logoutview/25533)
