Urls.py:URL Distributor (Routing profile)
The URL configuration (URLconf) is like the directory of the Web site that Django supports. Its essence is the URL pattern and the mapping table between the view functions to invoke for that URL pattern. That's how you tell Django to call that code for that URL and call that code for that URL. The loading of the URL begins in the configuration file.
When you execute django-admin.py startproject , the script automatically builds a copy of the URLconf (that is, the urls.py file) for you. In a settings.py file that is automatically created at the same time, create a variable root_urlconf whose value is the module name of the root URLCONF. The default value is the module name of the urls.py file.
For example: The root of my Django project is named "Hello_django" and the default value for root_urlconf is "Hello_django.urls".
Urlpatterns two different forms:
The first type:
The second (new version of Django is deprecated):
URL pattern:
Urlpatterns = [
URL (regular expression, views function, parameter, alias, prefix)
]
Source:
URL (r ' ^hello/$ ', Views.hello)
The form of the object can be written as a string: URL (r ' ^hello/$ ', ' Hello.views.hello ')
Django Notes urls.py Detailed