Reputation:
error : from django.conf.urls import url ImportError: cannot import name 'url' from 'django.conf.urls'
-version Django==4.0.1 django-rest-auth==0.9.5
Pl help me.Thank you in advance
url.py
# Core Django imports
from django.contrib import admin
from django.urls import path, include
from django.urls import re_path,include
# from django.conf.urls import url,include
from django.conf import settings
# Rest framework imports
from rest_framework import permissions
# Simple JWT imports
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
schema_view = get_schema_view(
openapi.Info(
title="Heathy Living Guide API",
default_version='v1',
description="Heathy Living Guide",
),
public=True,
permission_classes=(permissions.AllowAny,),
)
urlpatterns = (
path('admin/', admin.site.urls),
path('api/authentication/', include('apps.authentication.urls'),authentication'),
path('api/users/', include('apps.users.urls'), name='users'),
path('rest-auth/', include('rest_auth.urls')),
# re_path(r'^rest-auth/', include('rest_auth.urls'))
)
urlpatterns += [
path('api/swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('api/redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc')
]
Upvotes: 8
Views: 7120
Reputation: 1
Replace from django.conf.urls import url
with from django.urls import re_path
.
urlpatterns = (
re_path('admin/', admin.site.urls),
re_path('api/authentication/', include('apps.authentication.urls'),authentication),
re_path('api/users/', include('apps.users.urls'), name='users'),
re_path('rest-auth/', include('rest_auth.urls')),
# re_path(r'^rest-auth/', include('rest_auth.urls'))
)
Upvotes: 0
Reputation: 311
According to the drf documentation:
Django-rest-auth is the original project, but is not currently receiving updates.
Dj-rest-auth is a newer fork of the project.
If you still want to use django-rest-auth, there are several deprecated calls to the API which you need to replace:
For django.conf.urls use
from django.urls import re_path as url
For ugettext use
from django.utils.translation import gettext_lazy as _
for force_text use
from django.utils.encoding import force_str as force_text
Upvotes: 10
Reputation: 676
django-rest-auth is not supporting django 4.0. django-rest-auth
looks abandoned, last commit was 3 years ago.
Upvotes: 8