Old data on view after record delete

I have been following a wonderful four hour crash course on another platform, and things went swimmingly. At time 3:37hr 3:42hr of 3:45hr, I ran into a fundamental breakdown of my understanding.

A “raw” delete class based view, is deleting a record in the “Courses” dataset. After delete, the view named ‘courses-list’ is displayed listing all the records currently in the database… except, it is still showing the old record as if it was still there. Log into admin, and the record is definitely deleted.

SUPER DUPER CLUE and exactly why I know this is a lack of my understanding fundamentally. If refresh the page, old record still there. Go to somewhere else in the website and return to “/courses/”, deleted record still there. Clear browser cache and reload page, record still there. BUT if I stop the Django server and restart, hit refresh on the page, the deleted record is gone.

Please help, and let me know what else you need from me.
EDIT - Python 3.6.9 and Django 2.0.7 on Ubuntu 18.04

**courses.views.py**
    class CourseView(View):
	template_name = "courses/course_detail.html" # DetailView
	def get(self, request, id=None, *args, **kwargs):
		# GET method  
		context = {}
		if id is not None:
			obj = get_object_or_404(Course, id=id)
			context['object'] = obj

		return render(request, self.template_name, context)

class CourseListView(View):
	template_name = "courses/course_list.html"
	queryset = Course.objects.all()

	def get_queryset(self):
		return self.queryset

	def get(self, request, *args, **kwargs):
		context = {"object_list": self.get_queryset()}
		return render(request, self.template_name, context)

    class CourseDeleteView(View):
	template_name = "courses/course_delete.html" 
	def get_object(self):
		id = self.kwargs.get('id')
		obj = None
		if id is not None:
			obj = get_object_or_404(Course, id=id)

		return obj

	def get(self, request, id=None, *args, **kwargs):
		# GET method
		context = {}
		obj = self.get_object()
		if obj is not None:
			context['object'] = obj

		return render(request, self.template_name, context)

	def post(self, request, id=None, *args, **kwargs):
		# POST method  
		context = {}
		obj = self.get_object()
		if obj is not None:
			obj.delete()
			context['object'] = None
			return redirect('/courses/')

		return render(request, self.template_name, context)

**courses.urls.py**
from django.urls import path
from .views import (
	CourseView,
	CourseListView,
	CourseCreateView,
	CourseUpdateView,
	CourseDeleteView
)

app_name = 'courses'

urlpatterns = [
	path('', CourseListView.as_view(), name='courses-list'),

	path('create/', CourseCreateView.as_view(), name='courses-create'),
    path('<int:id>/', CourseView.as_view(), name='courses-detail'), # keyword arg of pk or a slug default
    path('<int:id>/update/', CourseUpdateView.as_view(), name='courses-update'),
    path('<int:id>/delete/', CourseDeleteView.as_view(), name='courses-delete')
]

**courses_delete.html**
{% extends 'base.html' %}

{% block content %}

<form action='.' method='POST'>{% csrf_token %}

    <h1>Do you want to delete the course "{{ object.title }}"?</h1>

    <p><input type='submit' value='Yes' /> <a href='../'>Cancel</a></p>

</form>

{% endblock %}

**course_list.html**
{% extends 'base.html' %}

{% block content %}

<!-- {{ object_list }} -->

{% for instance in object_list %}

    <p>{{ instance.id }} - {{ instance.title }}</p>

{% endfor %}

{% endblock %}

Do you have any page caching set up in your settings.py?

What happens if you go to this page from another browser (or from a new private / incognito window?)

What happens if you completely close your browser then re-open it and go to that page?

Hi Ken,

Thanks for your help!

We did not setup any caching with this project that I know of.

Closing the browser, going to the page from another browser, and a private incognito window still displays the old record. I can even see the GET call in my terminal window:
“GET /courses/ HTTP/1.1 200 480”

If you peek in admin, the record is definitely gone. The only thing that makes the record go away, is restarting the Python server.

**settings.py**
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production

# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = '*****'

# SECURITY WARNING: don't run with debug turned on in production!

DEBUG = True

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [

    'django.contrib.admin',

    'django.contrib.auth',

    'django.contrib.contenttypes',

    'django.contrib.sessions',

    'django.contrib.messages',

    'django.contrib.staticfiles',

# Third Party

# Own

    'pages',

    'products',

    'blog',

    'courses',

]

MIDDLEWARE = [

    'django.middleware.security.SecurityMiddleware',

    'django.contrib.sessions.middleware.SessionMiddleware',

    'django.middleware.common.CommonMiddleware',

    'django.middleware.csrf.CsrfViewMiddleware',

    'django.contrib.auth.middleware.AuthenticationMiddleware',

    'django.contrib.messages.middleware.MessageMiddleware',

    'django.middleware.clickjacking.XFrameOptionsMiddleware',

]

ROOT_URLCONF = 'rtp_store.urls'

TEMPLATES = [

    {

        'BACKEND': 'django.template.backends.django.DjangoTemplates',

        'DIRS': [os.path.join(BASE_DIR, "templates")],

        'APP_DIRS': True,

        'OPTIONS': {

            'context_processors': [

                'django.template.context_processors.debug',

                'django.template.context_processors.request',

                'django.contrib.auth.context_processors.auth',

                'django.contrib.messages.context_processors.messages',

            ],

        },

    },

]

WSGI_APPLICATION = 'rtp_store.wsgi.application'

# Database

# *****

DATABASES = {

    'default': {

        'ENGINE': 'django.db.backends.sqlite3',

        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

    }

}

# Password validation

# ****

AUTH_PASSWORD_VALIDATORS = [

    {

        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',

    },

    {

        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',

    },

    {

        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',

    },

    {

        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',

    },

]

# Internationalization

# ****

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)

# *****

STATIC_URL = '/static/'

Note: When you’re posting code or html here, enclose it between lines of three backtick - ` characters to preserve formatting. This means you’ll have a line of ```, then your code, then another line of ```.
If you would, please edit your reply here by adding ``` before and after your settings. (separate lines, on their own)

Are you running your application through runserver, runserver_plus, or within the context of gunicorn, uwsgi, or apache?

Gosh thanks so much for the formatting help, I was just poking around the forum trying to figure that out.

I am running through ‘runserver’ as this is just a dev environment. Using ’ python3-venv’ as a virtual environment.