Django 路由系统URL

a. /index/                               ->  函数或类
        b. /index/(d+)                            ->  函数或类
        c. /index/(?P<nid>d+)                   ->  函数或类
        d. /index/(?P<nid>d+) name='root'          ->  函数或类
            reverse()
            {% url 'root' 1%}
        e. /crm/    include('app01.urls')        -> 路由分发
        
        f. 默认值
            url(r'^index/', views.index, {'name': 'root'}),
        
            def index(request,name):
                print(name)
                return HttpResponse('OK')
    
        g. 命名空间
            
            /admin/    include('app01.urls',namespace='m1')
            /crm/      include('app01.urls',namespace='m1')
            
            app01.urls
            /index/    name = 'n1'
            
            
            reverser('m1:n1')

a. /index/                               ->  函数或类b. /index/(d+)                    ->  函数或类c. /index/(?P<nid>d+)  ->  函数或类d. /index/(?P<nid>d+) name='root' ->  函数或类reverse(){% url 'root' 1%}e. /crm/    include('app01.urls')        -> 路由分发f. 默认值url(r'^index/', views.index, {'name': 'root'}),def index(request,name):print(name)return HttpResponse('OK')g. 命名空间/admin/    include('app01.urls',namespace='m1')/crm/      include('app01.urls',namespace='m1')app01.urls/index/    name = 'n1'reverser('m1:n1')

原文地址:https://www.cnblogs.com/anhao-world/p/14650725.html