我正在尝试将Django项目中的URL从URL转换为路径。
这就是我现在拥有的内容,我在最后一个逗号中得到了无效的语法
知道为什么吗?有什么我想念的吗
urlpatterns = [
path(
'favicon.ico',
RedirectView.as_view(
url=staticfiles_storage.url('assets/icons/favicon.ico'),
permanent=False
),
name="favicon"
),
path('bets/', include('bets.paths'),
path('login/', auth_views.login, {'template_name': 'base_login.html'}, name='login'),
path('logout/', auth_views.logout, {'next_page': '/'}, name='logout'),
path('password_reset/', auth_views.password_reset,
{'template_name': 'registration/password_reset_form.html'}, name='password_reset'),
path('password_reset/done/', auth_views.password_reset_done,
{'template_name': 'registration/password_reset_done.html'}, name='password_reset_done'),
path('reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/',
auth_views.password_reset_confirm,
{'template_name': 'registration/password_reset_confirm.html'},
name='password_reset_confirm'),
path('reset/done/', auth_views.password_reset_complete,
{'template_name': 'registration/password_reset_complete.html'},
name='password_reset_complete'),
path('admin/', admin.site.urls),
]
答案 0 :(得分:0)
我已经为您重新格式化了代码(使用autopep8 + vscode)并修复了丢失的)
:
urlpatterns = [
path(
'favicon.ico',
RedirectView.as_view(
url=staticfiles_storage.url('assets/icons/favicon.ico'),
permanent=False
),
name="favicon"
),
path('bets/', include('bets.paths')),
path('login/', auth_views.login,
{'template_name': 'base_login.html'}, name='login'),
path('logout/', auth_views.logout, {'next_page': '/'}, name='logout'),
path('password_reset/', auth_views.password_reset,
{'template_name': 'registration/password_reset_form.html'}, name='password_reset'),
path('password_reset/done/', auth_views.password_reset_done,
{'template_name': 'registration/password_reset_done.html'}, name='password_reset_done'),
path('reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/',
auth_views.password_reset_confirm,
{'template_name': 'registration/password_reset_confirm.html'},
name='password_reset_confirm'),
path('reset/done/', auth_views.password_reset_complete,
{'template_name': 'registration/password_reset_complete.html'},
name='password_reset_complete'),
path('admin/', admin.site.urls),
]
功劳归于:jasonharper