Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

147
Views
DRF - from django.conf.urls import url in Django 4.0

I've a project in django 3.2 and I've updated (pip install -r requirements.txt) to version 4.0 (new release) and I've currently the below error when I run the server in a virtual environment. I use DRF.

Can't import => from rest_framework import routers in urls.py

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

9 months ago · Santiago Trujillo
1 answers
Answer question

0

As per the Django docs here:

url(regex, view, kwargs=None, name=None)¶ This function is an alias to django.urls.re_path().

Deprecated since version 3.1: Alias of django.urls.re_path() for backwards compatibility.

django.conf.urls.url() was deprecated since Django 3.1, and as per the release notes here, is removed in Django 4.0+.

You can resolve the issue using path or re_path.

https://docs.djangoproject.com/en/4.0/ref/urls/

9 months ago · Santiago Trujillo Report
Answer question
Find remote jobs