Python 未找到django rest验证URL
我试图实现django rest auth,但url无法识别,并抛出404错误。“rest\u auth”添加到已安装的应用程序中,路径也包含在url.py文件中Python 未找到django rest验证URL,python,django,django-rest-framework,django-rest-auth,Python,Django,Django Rest Framework,Django Rest Auth,我试图实现django rest auth,但url无法识别,并抛出404错误。“rest\u auth”添加到已安装的应用程序中,路径也包含在url.py文件中 Request URL: http://127.0.0.1:8000/api/v1/rest-auth/login/ Using the URLconf defined in blog_project.urls, Django tried these URL patterns, in this order: admin/ ap
Request URL: http://127.0.0.1:8000/api/v1/rest-auth/login/
Using the URLconf defined in blog_project.urls, Django tried these URL patterns, in this order:
admin/
api/v1/ <int:pk>/
api/v1/
api-auth/
api/v1/rest-auth ^password/reset/$ [name='rest_password_reset']
api/v1/rest-auth ^password/reset/confirm/$ [name='rest_password_reset_confirm']
api/v1/rest-auth ^login/$ [name='rest_login']
api/v1/rest-auth ^logout/$ [name='rest_logout']
api/v1/rest-auth ^user/$ [name='rest_user_details']
api/v1/rest-auth ^password/change/$ [name='rest_password_change']
The current path, api/v1/rest-auth/login/, didn't match any of these.
下面是my URL.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')),
]
我不知道代码有什么问题。在
url.py
中,您需要为api/v1/rest-auth/login/
实现一个url。在url.py
中,您需要为api/v1/rest-auth/login/
实现一个url。现在它可以正常工作了。
路径('api/v1/rest-auth/',include('rest\u-auth.url'))找到了原因,只是路径中缺少一个“/”。现在它可以正常工作了。 路径('api/v1/rest-auth/',include('rest\u-auth.url'))您的问题就在这里
path('api/v1/rest-auth', include('rest_auth.urls')),
您需要在URL字符串的末尾添加一个/
,如下所示-
path('api/v1/rest-auth/', include('rest_auth.urls')),
你的问题就在这里
path('api/v1/rest-auth', include('rest_auth.urls')),
您需要在URL字符串的末尾添加一个/
,如下所示-
path('api/v1/rest-auth/', include('rest_auth.urls')),