method's name in MIDDLEWARE

12 views
Skip to first unread message

shahab emami

unread,
Apr 15, 2017, 1:47:59 PM4/15/17
to Django users
hello

i want to learn MIDDLEWARE in django  .

i created this:

class SimpleMiddleware(object):

    def process_request(self, request):
        print("%%%%%%%%%%%%%%%%")

and i added in settings.py. then as you probably know i see "%%%%%%" in console with every click.
that is the exact thing that i except.

but when i change name of method:

    def hello(self, request):
        print("%%%%%%%%%%%%%%%%")
  it doesn't work anymore  .

is process_request a keyword? where can i find list of this names ?

m712 - Developer

unread,
Apr 15, 2017, 2:05:47 PM4/15/17
to shahab emami, Django users

You should take a look at https://docs.djangoproject.com/en/1.11/topics/http/middleware/#process-view
It is not a reserved keyword but simply a function that is called by the Django middleware system.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/504db6b6-c18f-4c2b-8453-9d6db429b966%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages