限制对Django应用程序中所有页面的访问 [英] Restrict access to all the pages in a django app
本文介绍了限制对Django应用程序中所有页面的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想限制对所有 url(r'^ engg/',include('engg.urls')),
和仅当 request.user.profile.type为'E'
时,才允许用户访问它们.除了创建装饰器并将其应用于engg/views.py中的每个单个视图外,有什么简单的方法?
I want to restrict access to all url(r'^engg/', include('engg.urls')),
and
allow users to access them only if request.user.profile.type is 'E'
. What is a simple way to do this except creating a decorator and applying it to every single view in engg/views.py ?
推荐答案
If you don't want to decorate each view separately you should use use a middleware.
应该不难适应本线程.
这篇关于限制对Django应用程序中所有页面的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文