django's url Management: include ()

Usage: If you need to call other urls urls in the current relatively easy to use

Role: urlpatterns weed out path matched to the front portion, the remaining portion of the process to include the urls

Chestnuts 1:

from django.conf.urls import include, url
 
urlpatterns = [
    # ... snip ...
    url(r'^community/', include('django_website.aggregator.urls')),
    url(r'^contact/', include('django_website.contact.urls')),
    # ... snip ...
]

Chestnuts 2:

from django.conf.urls Import the include, URL 
 
from apps.main Import views AS main_views
 from Credit Import views credit_views AS 
 
# Note that this may be another threw matching a list of files at the same 
extra_patterns = [ 
    URL (R & lt ' ^ Reports / $ ' , credit_views.report), 
    URL (R & lt ' ^ Reports / (? P <ID> [0-9] +) / $ ' , credit_views.report), 
    URL (R & lt ' ^ CHARGE / $ ' , credit_views. CHARGE), 
] 
 
the urlpatterns = [ 
    URL (R & lt ' ^ $ ', main_views.homepage),
    url(r'^help/', include('apps.help.urls')),
    url(r'^credit/', include(extra_patterns)),
]

Examples Source: https: //www.cnblogs.com/LuoDa/p/5406912.html

Guess you like

Origin www.cnblogs.com/Zarax/p/11853176.html