Django2.2 url path error

1
2
3
WARNINGS:
?: (2_0.W001) Your URL pattern 'nagios/alert/(?P<pk>\d+)/delete/' [name='nagios-alert-delete'] has a route that contains '(?P<', begins with a '^', or ends with a '$'. This was likely an oversight when migrating to django.urls.path().
?: (2_0.W001) Your URL pattern 'nagios/alert/(?P<pk>\d+)/update/' [name='nagios-alert-edit'] has a route that contains '(?P<', begins with a '^', or ends with a '$'. This was likely an oversight when migrating to django.urls.path().

搜索了一下,URL中有正则表达式的需要使用re_path代替path,修改后修复

1
2
re_path('nagios/alert/(?P<pk>\d+)/update/', views.AlertEditView.as_view(), name='nagios-alert-edit'),
re_path('nagios/alert/(?P<pk>\d+)/delete/', views.AlertDeleteView.as_view(), name='nagios-alert-delete'),
1
2
3
4
5
6
7
8
9
(study-xiaofanzhuo) [tianfei@tianfei-pc xiaofanzhuo]$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
April 30, 2019 - 16:40:40
Django version 2.2, using settings 'xiaofanzhuo.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
坚持原创技术分享,您的支持将鼓励我继续创作!