Reputation: 2693
I have defined a middleware class. and i have added it to the middleware_classes attribute in setting. When a request comes in, the middleware class gets created (the debugger catches the code when the breakpoint is on the class CommonFiilter(): line)
Now i expect the function def process_template_response(self, request, response): to get called. I have debug point on the inside of the function and the debugger never traps the execution. The debugger, though, traps the execution at the line where the function name and parameters are defined. This is the class:
class CommonFilter():#<---- debugger breaks here
def process_template_response(self, request, response): #<--- debugger breaks here
if response.template_name=='store/index2.html': #<--- NOT HERE (or after this line)
catnames=getCategories()
response.context_data.update({'catnames':catnames,'user':request.GET.get(key='user',default=None)})
return response
Also tried this:
class CommonFilter():#<---- debugger breaks here
def process_template_response(self, request, response):#<---- debugger breaks here
if response.template_name=='store/index2.html':#<--- NOT HERE (or after here)
catnames=getCategories()
response.context_data['catnames']=catnames
response.context_data['user']=request.GET.get(key='user',default=None)
return response
Just in case, this is the setting MIDDLEWWARE_CLASSES variable:
MIDDLEWARE_CLASSES = (
'store.models.CommonFilter',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
store is an app in this project and ofcourse CommonFilter is defined in models.py.
Why is the function process_template_response function not being executed?
Thanks for your time and kind concern.
Upvotes: 0
Views: 649