regular expression not matching.
The current path, attendance/B-2019-07-05, didn't match any of these.
从django.urls导入路径re_path 从django.contrib.auth导入视图作为auth_views 来自。将视图作为视图导入
urlpatterns = [
path('plan/', views.plan_view, name='plan_name'),
path('journey/', views.Journey_view),
path('attendance/', views.attendance_view),
re_path(r'^attendance/(?P<date>\[AB]-\d{4}-\d{2}-\d{2})/$', views.index, name='update_data'),
path('login/', views.user_login, name='login',),
path('', views.user_logout, name='logout_now'),
path('logout/', views.logout_view, name='logout_name'),
path('register/', views.register),
path('attendance/', views.attendance_view, name='attendance'),
path('passwordchange/', views.PasswordChangeView, name='change_password'),
path('passwordchangedone/', views.PasswordChangeDoneView, name='password_change_done'),
# path('attendance/', views.attendance_view),
re_path(r'^export/csv/$', views.export_report_csv, name='export_report_csv'),
]
答案 0 :(得分:0)
您的re_path
包含反斜杠:
r'^attendance/(?P<date>\[AB]-\d{4}-\d{2}-\d{2})/$'
# ^
您应该删除此代码,因为通过转义[
,您可以指定用户*从字面上写[
,以便它接受URL attendance/[AB]-2019-07-04/
。
re_path
应该看起来像:
re_path(r'^attendance/(?P<date>[AB]-\d{4}-\d{2}-\d{2})/$', views.index, name='update_data'),