A
A
Alexander Zakharov2022-04-08 04:00:26
Django
Alexander Zakharov, 2022-04-08 04:00:26

What if Django 4.0 says cannot import name 'url' from 'django.conf.urls' on rest_auth?

Good morning-afternoon.

What should I do if:
Django starting from version 4 gives - "cannot import name 'url' from 'django.conf.urls'" when creating url from rest_auth?

Main urls.py:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/v1/', include('posts.urls')),
    path('api-auth/', include('rest_framework.urls')),
    path('api/v1/rest-auth/', include('rest_auth.urls')),
]


settings.py :
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
    'posts',

    'rest_framework',
    'rest_framework.authtoken',
    'rest_auth',
]

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated',
    ],
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.TokenAuthentication',
    ],
}


Tried to solve with these ways:
https://stackoverflow.com/questions/70319606/impor...
Didn't help.

Or is there some analogue to this module for the 4th version?

I study Django Rest from the book "Django for APIs"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-04-08
@CleRleQ

Well then rest_auth is something old, you don't need to use it, or use it with old versions of django, but what's the point?

I study Django Rest from the book "Django for APIs"
Well, that's the problem of studying from books, over time, the information there becomes outdated, study from official docks.
APD went to see what kind of project it is https://github.com/Tivix/django-rest-auth it clearly says what to do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question