开发者

django-sorting and django-pagination: middleware order

开发者 https://www.devze.com 2023-03-27 12:43 出处:网络
I am using django-pagination and django-sorting together for one of my views. Both 开发者_JS百科these have custom middleware to sort and paginate. So is the order of middleware important in this case?

I am using django-pagination and django-sorting together for one of my views. Both 开发者_JS百科these have custom middleware to sort and paginate. So is the order of middleware important in this case?


In this case the order is not important:

  • django-pagination looks for a variable page and
  • django-sorting looks for sort and dir variables.

So both just populate the request object with their variables. If eg some of these required the django.auth framework, order matters: the auth-using framework must come after 'django.contrib.auth.middleware.AuthenticationMiddleware' etc.

Django middleware classes are easily read, so looking at the source, helps a lot :-) understanding what is going on.

0

精彩评论

暂无评论...
验证码 换一张
取 消