Last active
May 3, 2020 05:09
-
-
Save hamedsj/83907cc5e4d2217b05ede97d6fe80a29 to your computer and use it in GitHub Desktop.
MyMiddleware.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponse | |
from django.utils.deprecation import MiddlewareMixin | |
class MyMd(MiddlewareMixin): | |
def process_request(self, request): | |
if "p" in request.GET.keys(): | |
return HttpResponse("Hello World =)") | |
return None | |
def process_view(self, request, view_function, view_args, view_kwargs): | |
if view_function.__name__ == "process_view_test": | |
return HttpResponse("This method only work for this view =)") | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment