Django - application software

I know the following methods for adding middlewares 1) Adding a special middleware component to django using MIDDLEWARE_CLASSES

MIDDLEWARE_CLASSES = (
     '......'
    'path.to.custom.middlware',)

2) Adding middleware to view with decorate_from_middlware

cache_page = decorator_from_middleware(CacheMiddleware)

@cache_page(3600)
def my_view(request):
    pass

My request is how to create a middleware application class like

APPSPECIFIC_MIDDLEWARE_CLASSES = ( 'path.to.middlwareclass1',
 'path.to.middlwareclass2',
 'path.to.middlwareclass3', )

is middlwareclass either a function or a class? Is there anything to do this using url or any other method. Or is the second method the only way to add all middleware classes separately to the view?

: http://python-social-auth.readthedocs.org/en/latest/pipeline.html , SOCIAL_AUTH_PIPELINE . .

Advance

+4
1

, , django , . process_view, , - , ( ).

, , , - - mixin base view, .

+3

Source: https://habr.com/ru/post/1615009/


All Articles