开发者

Restrict access to all the pages in a django app

开发者 https://www.devze.com 2023-03-06 00:40 出处:网络
I want to restri开发者_Python百科ct 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

I want to restri开发者_Python百科ct 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.

Shouldn't be to hard to adapt the examples in this thread.

0

精彩评论

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

关注公众号