Please help. Django logout authentication gives a blank page with No page source

I am following a tutorial by Corey Schafer on YouTube. Part 7 Login and Logout System. My register.html works fine. The login.html also works fine. But when I try to logout using 127.0.0.1:8000/logout, I get a blank page. Even when I check the page source it is blank. Here is the register.html file

{% extends "zacsBlog/base.html" %}
{% load crispy_forms_tags %}
{% block content %}
    <div class="content-section">
        <form method="POST">
            {% csrf_token %}
            <fieldset class="form-group">
                <legend class="border-bottom mb-4">Join Today</legend>
                {{ form|crispy }}
                <!-- {{ form.as_p }} -->
            </fieldset>
            <div class="form-group">
                <button class="btn btn-outline-info" type="submit">Sign Up</button>
            </div>
        </form>
        <div class="border-top pt-3">
            <small class="text-muted">
                Already Have An Account? <a class="ml-2" href="{% url 'login' %}">Sign In</a>
            </small>
        </div>
    </div>
{% endblock content %}

Then the login.html file

{% extends "zacsBlog/base.html" %}
{% load crispy_forms_tags %}
{% block content %}
    <div class="content-section">
        <form action="{% url 'blog-home' %}" method="POST">
            {% csrf_token %}
            <fieldset class="form-group">
                <legend class="border-bottom mb-4">Log In</legend>
                {{ form|crispy }}
                <!-- {{ form.as_p }} -->
            </fieldset>
            <div class="form-group">
                <button class="btn btn-outline-info" type="submit">Login</button>
            </div>
        </form>
        <div class="border-top pt-3">
            <small class="text-muted">
                Don't Have An Account? Create An Account Here? <a class="ml-2" href="{% url 'register' %}">Sign Up Now</a>
            </small>
        </div>
    </div>
{% endblock content %}

the logout.html file:-

{% extends “zacsBlog/base.html” %}
{% block content %}

You have been logged out




Log In Again


{% endblock content %}

This is my views.py file

from django.shortcuts import render, redirect
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import logout
from django.contrib.auth.views import LogoutView
from django.contrib import messages
from .forms import UserRegisterForm

Create your views here.

def register(request):
if request.method == ‘POST’:
form = UserRegisterForm(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data.get(‘username’)
messages.success(request, f’Your account {username} has been created. You can now login to the blog and create content!‘)
# messages.success(request, f’Account created for {username}!’)
return redirect(‘login’)
# return redirect(‘blog-home’)
else:
form = UserRegisterForm()
return render(request, ‘users/register.html’, {‘form’: form})

and the urls.py file

from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.urls import path, include
from users import views as user_views

urlpatterns = [
path(‘admin/’, admin.site.urls),
path(‘register/’, user_views.register, name=‘register’),
path(‘login/’, auth_views.LoginView.as_view(template_name=‘users/login.html’), name=‘login’),
path(‘logout/’, auth_views.LogoutView.as_view(template_name=‘users/logout.html’), name=‘logout’),
# path(‘login/’, auth_views.LoginView.as_view(template_name=‘users/login.html’), name=‘login’),
# path(‘logout/’, auth_views.LogoutView.as_view(), name=‘logout’),
path(‘’, include(‘zacsBlog.urls’)),
path(‘blog/’, include(‘zacsBlog.urls’)),
]

The logout.html file seems to work perfectly fine in my forum post. How come it does not show up on the webpage?

That tutorial is seriously out-of-date. A quick glance shows that it looks like it was created for Django 2.1 - there’s a lot that has changed since then. You’re going to learn wrong information trying to follow it and learn from it.

Wow!!! Now let me turn back. It is said…“No matter how far you have gone on a wrong road. Turn back. So I guess I turn back here. Thanks for the advice.”

To be honest I tried the Django Girls tutorial and got up to where I am supposed to deploy to Python Anywhere. I got confused. I remember you advised me to go back and check for a step I had missed. I think I did so and I now got my web app up and running. But I still am sort of confused with the deployment part.

Hi Ken Whitesell I would like to ask that just for this time ignore the fact that the Corey Schafer tutorial uses Django==.1 and help me resolve the problem for the following reasons.
1)I find it easier to follow video tutorials because I am 73 years old and I have cataracts in my eyes. (I am trying to raise $500 for the cataract surgery). Meanwhile I want to keep my mind occupied

) watching the videos is much easier than trying to read(maybe that is why I got confused with the Django Girls tutorial where I had to deploy my web app to Python Anywhere).

According to Robert Greene “mastery of any skill should take at least 20,000 hours of practice. This rule emphasizes the sheer amount of work and dedication it takes to become a master in any field. It suggests that for someone who loves what they do, 20,000 hours is merely an invitation to explore their craft more deeply.”

I derive joy from computer programming- Python, SQL, JavaScript, HTML, CSS, PostgreSQL, Django, C#, Unity 3D game engine. Just like many people derive joy from Baseball, Cricket, Basketball, American football(in America), soccer/football rest of the world.

Seeing the webpage move, or a registration page saving an entry to my Admin dashboard gives me joy. So please. Help me. Even if the tutorial is old. It will be part of my 20,000 hours of practice. How can I get the logout page working. (The register.html and login.html) work fine. They are all in the users/templates/users directory. When I finish with this tut(don’t want to start something and not finish it; when I finish with this I will look for tutorials on Django 5.x. There is one by Dave Gray) Preferably I want video tuts until I can get the cataract surgery done. Thank you for your patience and your understanding

The issue isn’t so much just getting the logout page working. It’s the other related issues that are likely to be raised throughout the tutorial because of this fix and the other fixes that are going to be necessary along the way - and quite honestly, I don’t have the time to dedicate addressing all the individual issues that are going to crop up because of the age of that tutorial.

As a side note, that oft-misquoted and mis-applied quote about 20,000 hours comes with the frequently ignored requirement that those hours be spent productively in the advancement of your knowledge. Spending your time learning things that are no longer true is not helpful, and is actually harmful in your attempt to become proficient with Django as it’s going to create confusion and misunderstandings when you see information contradicting what you’re learning from more appropriate resources.

I just saw the news about Hurricane Milton. I hope you , tour family and your loved ones are safe from the devastating effects of the hurricane. Somehow we here in Nigeria do not know and have never experienced such storms.

Okay. I think I understand your concern, Thanks. I guess I will need to patiently go back to the Awesome Django site and look for something for suitable for a beginner like me

You are right you know. It really makes sense to learn what will advance one’s knowledge. Thanks. I am learning alot by tapping into your wealth of wisdom. Thanks for your understanding