Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

PyTest warning - RemovedInDjango40Warning: django.conf.urls.url() is deprecated in favor of django.urls.re_path()

New member
Joined
Feb 9, 2023
Messages
8
when i'm using pytest to run test cases i'm getting 10 warnings -

Code:
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 warnings like this.
using django==3.2.4
djangorestframework==3.12.4
pytest-django==4.5.2
tried filterwarnings in setup.cfg
 
New member
Joined
Feb 9, 2023
Messages
8
You should use re_path instead of url as url is deprecated. Sample code snippet is given below:

Code:
from django.urls import re_path

urlpatterns = [
    re_path(r'^password/reset/$', PasswordResetView.as_view()),
    re_path(r'^password/reset/confirm/$', PasswordResetConfirmView.as_view()),
    re_path(r'^login/$', LoginView.as_view()),
    ...
]

Note: If a software is deprecated then, it may refer to a program or application that is no longer supported or maintained by its developer.
 
Top