Posted in Python onJuly 25, 2015
本文实例讲述了Python中Django框架利用url来控制登录的方法。分享给大家供大家参考。具体如下:
from django.conf.urls.defaults import patterns,url #or use login_required from django.contrib.admin.views.decorators import staff_member_required def login_url(regex, view, *p,**args): """ urlpatterns = patterns('', login_url(r'^$',direct_to_template, {'template': '1.html'}), ) """ return url(regex,staff_member_required(view),*p,**args) def login_patterns(*p): """ urlpatterns = login_patterns('', (r'^$',direct_to_template,{'template':'1.html'}), ) """ d=[] d.append(p[0]) for i in xrange(1,len(p)): d.append(login_url(*p[i])) return patterns(*d)
希望本文所述对大家的Python程序设计有所帮助。
Python中Django框架利用url来控制登录的方法
- Author -
Sephiroth声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@