Logout link giving error 405

I am trying to create a to do list watching a tutorial in order to learn the basics of Django.
The issue is that when I log out instead of getting the log in page I get an error 405. Also when I use the back arrow it takes me to the app content.
Any Ideas on how to solve this ? Following is the code


{% if request.user.is_authenticated %}
<a href="{% url 'logout' %}">Logout</a>

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


<h1>My To DO List</h1>
<a href="{% url 'task-create' %}">Add Task</a>

    {% for task in tasks %}
        <td><a href="{% url 'tasks' task.id %}">View</a></td>
        <td><a href="{% url 'task-update' task.id %}">Edit</a></td>
        <td><a href="{% url 'task-delete' task.id %}">Delete</a></td>
    {% empty %}
    <h1>No items in list </h1>
    {% endfor %}



<form method="POST">
    {% csrf_token %}
    <input type="submit" value="Login">


from django.urls import path 
from .views import TaskList, TaskDetails, TaskCrete, TaskUpdate, DeleteView, CustomLoginView
from django.contrib.auth.views import LogoutView

urlpatterns = [
    path('login/', CustomLoginView.as_view(), name='login'),
    path('logout/', LogoutView.as_view(next_page='login'), name='logout'),

    path('', TaskList.as_view(), name='tasks'),
    path('task/<int:pk>/', TaskDetails.as_view(), name='tasks'),
    path('task-create/', TaskCrete.as_view(), name='task-create'),
    path('task-update/<int:pk>/', TaskUpdate.as_view(), name='task-update'),
    path('task-delete/<int:pk>/', DeleteView.as_view(), name='task-delete'),



from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy

from django.contrib.auth.views import LoginView

from django.contrib.auth.mixins import LoginRequiredMixin

from .models import Task

class CustomLoginView(LoginView):
    template_name = 'base/login.html'
    fields = '__all__'
    redirect_authenticated_user = True
    def get_success_url(self):
        return reverse_lazy('tasks')


class TaskList(LoginRequiredMixin, ListView):
    model = Task
    context_object_name = 'tasks'
class TaskDetails(DetailView):
    model = Task
    context_object_name = 'task'
    template_name = 'base/task.html'
class TaskCrete(CreateView):
    model = Task
    fields = '__all__'
    success_url = reverse_lazy('tasks')
class TaskUpdate(UpdateView):
    model = Task
    fields = '__all__'
    success_url = reverse_lazy('tasks')
class DeleteView(DeleteView):
    model = Task
    context_object_name = 'task'
    success_url = reverse_lazy('tasks')

The tutorial is obsolete.

See the thread and related links at Showing `Method Not Allowed (GET): /users/logout/`

Instead of trying to learn Django from some random YouTube videos, I suggest you work your way through the Official Django Tutorial and the Django Girls Tutorial, and then find additional resources at GitHub - wsvincent/awesome-django: A curated list of awesome things related to Django

Thank you Ken ! Much appreciated.