In the django online course, the teacher uses the url() function to invoke views and use regular expressions in the urlpatterns list. I saw other examples on youtube of this. eg.
from django.contrib import admin from django.urls import include from django.conf.urls import url urlpatterns = [ path('admin/', admin.site.urls), url(r'^polls/', include('polls.urls')), ]
However, when viewing a Django tutorial, they use path() , not eg:
from django.urls import path from . import views urlpatterns = [ path('', views.index, name="index"), ]
Also, regular expressions don't seem to work with the path() function, since using path(r'^$', views.index, name="index") will not find the mysite.com/polls/ .
Uses path() without a regex, suitable for further advancement? Is url() more powerful but more complex, so they use path() to start with us? Or is it the case of various tools for different tasks?
source share