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

8.3k views Asked by At

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 !

3

There are 3 answers

2
Nivethithaa Athithan On

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

0
dgw On

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

Use django.urls.re_path instead.

0
Shezan Mahamud On

for Django 4.0.

from django.urls import re_path as url