dj_rest_auth中的PyTest警告-已在Django 40中删除警告:django.conf.urls.url()已被弃用,取而代之的是django.urls.re_path()

ldioqlga  于 2023-02-17  发布在  Go
关注(0)|答案(1)|浏览(150)

当我使用pytest运行测试用例时,我收到了10条警告-

RemovedInDjango40Warning: django.conf.urls.url() is deprecated in favor of django.urls.re_path().
    url(r'^password/reset/$', PasswordResetView.as_view(),
RemovedInDjango40Warning: django.conf.urls.url() is deprecated in favor of django.urls.re_path().
    url(r'^password/reset/confirm/$', PasswordResetConfirmView.as_view(),
RemovedInDjango40Warning: django.conf.urls.url() is deprecated in favor of django.urls.re_path().
    url(r'^login/$', LoginView.as_view(), name='rest_login'),

有10个这样的警告。我已经在setup.cfg中尝试过filterwarnings。错误的来源是:C:\Users\suraj\AppData\Local\Programs\Python\Python39\lib\site-packages\dj_rest_auth\registration\urls
已编辑-此警告已解决,但现在我将错误发送到dj-rest-auth ImproperlyConfigured at /api/v1/auth/registration/account-email-verification-sent/

xnifntxz

xnifntxz1#

在检查源代码时,我可以看到较新版本的dj_rest_auth不再使用url,而是使用path。

urlpatterns = [
    # URLs that do not require a session or valid token
    path('password/reset/', PasswordResetView.as_view(), name='rest_password_reset'),
    path('password/reset/confirm/', PasswordResetConfirmView.as_view(), name='rest_password_reset_confirm'),
    path('login/', LoginView.as_view(), name='rest_login'),
    # URLs that require a user to be logged in with a valid session / token.
    path('logout/', LogoutView.as_view(), name='rest_logout'),
    path('user/', UserDetailsView.as_view(), name='rest_user_details'),
    path('password/change/', PasswordChangeView.as_view(), name='rest_password_change'),
]

因此,将dj_rest_auth更新为较新版本将修复此问题。请参阅release页面以获取可供选择的版本。

相关问题