I created a custom mysite/mymiddlewar.py file as follows…
class DoseControllerMiddleware(object):
def process_request(self, request):
"""
get ready to call the Dose Controller
"""
print("DoseControllerModdleware.process_request Hooray")
return None
This is in a file called mymiddleware located adjacent to mysite.settings.py
My settings looks like this…
MIDDLEWARE = [
‘django.middleware.security.SecurityMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘mysite.mymiddleware.DoseControllerMiddleware’,
‘django.middleware.common.CommonMiddleware’,
‘django.middleware.csrf.CsrfViewMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
‘django.contrib.messages.middleware.MessageMiddleware’,
‘django.middleware.clickjacking.XFrameOptionsMiddleware’,
]
When I runserver I get…
ModuleNotFoundError: No module named ‘mysite.mymiddleware’
I have tried it with a middleware folder with init with the mymiddleware.py in that folder and changed the path in MIDDLEWARE settings to match but ModuleNotFoundError.