请问老师,python3.7版urls.py文件里已经用path代替url, from django.urls import path, 那么下面2句话用path怎么写呢?谢谢。
url(r'^$', IndexView.as_view(), name='index'),
url(r'^address/(\d+)$', AddressAPI.as_view(), name='address'),
********************* urls.py ********************************
from django.conf.urls import url
from django.contrib import admin
from courses.views import IndexView, AddressAPI
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', IndexView.as_view(), name='index'),
url(r'^address/(\d+)$', AddressAPI.as_view(), name='address'),
]
urls.py的写法与Python版本无关,是Django框架的版本不同,我视频中用的1.11.x,Django 2.0及之后是
from django.urls import include, re_path, path
path是url路径匹配,re_path带正则的路径匹配
urlpatterns = [ path('admin/', admin.site.urls), path('', IndexView.as_view(), name='index'), repath(r'^address/(\d+)$', AddressAPI.as_view(), name='address'), ]
刚刚知道,这是JQuery, 这个问题请忽略。
另外,例子中js文件打开后,发现所有代码在一行,很难读,能帮忙分行吗?想了解里面代码意思,如果有相关的说明更好。谢谢。