'ImportError: cannot import name 'url' from 'django.conf.urls'

ImportError: cannot import name 'url' from 'django.conf.urls' (/home/chams/pfe_project/CarApp/venv/lib/python3.8/site-packages/django/conf/urls/_init_.py)

I can't find any mistakes in my code !



Solution 1:[1]

django.conf.urls.url was deprecated and removed in Django 4.0.

Use django.urls.re_path instead.

Solution 2:[2]

django.conf.urls.url() was deprecated in Django 3.0, and is removed in Django 4.0+. The easiest fix is to replace url() with re_path()

You will be using this,

from django.conf.urls import url

Instead use this:

from django.urls import re_path as url

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dgw
Solution 2 Nivethithaa Athithan