У меня есть следующий класс промежуточного программного обеспечения:
class CommonContextMiddleware:
def process_template_response(self, request, response):
# Get the context and top videos
context = response.context_data
...
# Add most_recent and most_viewed to the context...
context['most_recent'] = top_videos['most_recent'][:3]
context['most_viewed'] = top_videos['most_viewed'][:3]
# ...then continue rendering
return response
Однако, что бы я ни вставил в функцию, она никогда не вызывается. Я предполагал, что этот метод будет вызываться для каждого сгенерированного ответа шаблона, я не прав?
Заранее спасибо.