1) Distribution of URLs:
1, first write in the path inside the global URL, and the path name you want to distribute. 2, and create a new URL file in the path you want to distribute. In the distribution of the path name inside, the global URL inside the code, copy 3, and finally in the browser when opened, the command to add your distribution path full name.
Example: the original path
Urlpatterns= [
URL (R ' ^admin/', Admin.site.urls),
URL (R ' ^article/(\d{4}/\d{2}$) ', Views.article), #match the parentheses inside the
URL (R ' ^article/(? P<YEAR>\D{4})/(? P<DAYS>\D{2}) $ ' Span style= "font-size:15px" >#
URL ( r ' ^app01/' ,include ( ' app01.urls ')
]
New path:
= [
URL (R ' ^admin/', Admin.site.urls),
# URL (r ' ^article/(\d{4}/\d{2}$) ', views.article), # matches the parentheses inside the
# URL (r ' ^article/(? P<YEAR>\D{4})/(? P<DAYS>\D{2}) $ ', views.article), # matches the parentheses inside the
URL (R ' ^login/', Views.login),
]
It's inside.
2) Alias
1' alias '%} example: Urlpatterns = [url (r'^admin/', admin.site.urls), url (r' ) ^loginsdsd/', views.login,name='log'), in HTML with aliases in place of the previous name
3) The root directory, as its name implies, does not need to be followed by any path to directly access the data behind the URLs.
The root directory is expressed in $, urlpatterns = [ url (r'^admin/', admin.site.urls), url (r'^login/', Views.login,name='log'), url (r'^$', Admin.site.urls),] the last URL is the root directory, When you use a browser to access the page, you can directly use 127.0.0.1:8000 access, there is no need to add any path.
4) Rediect Jump function:
return render (Request, " login.html ") and return Rediect ( "/login.html/" return render (Request,login.html ") Just jump to login.html this page, no other action, and the URL of the call is not executed, and the path is the original path, when the user refreshed again, will be back to the original path of the page. return rediect ( ' / Login.html/ ") executes the function inside the URL, which is equivalent to calling the new function again,/login.html/ All code inside the function executes, and the path changes, and the user refreshes again without changing the
Django-url distribution, 2) alias, 3) root directory, 4) Rediect jump function: