1、先在views中创建通配方法
def mapping(request,method):
try:
#定义一个默认首页
if method == "":
method = "index"
return eval(method)(request)
except NameError,e:
msg = u"未知的请求"
logger.info(msg)
logger.info(str(e))
return HttpResponse(msg)
except Exception,e:
msg = u"请求遇到未知错误"
logger.info(msg)
logger.info(str(e))
return HttpResponse(msg)
2、在urls.py里添加urlpatterns,需要在上面import下mapping
url(r‘(.*)‘, mapping ,name=‘method‘)
原文:http://blog.51cto.com/4988084/2113541