gpt4 book ai didi

django - 如何解决此错误 "' password_reset' 不是 rest api django 中的注册命名空间”

转载 作者:行者123 更新时间:2023-12-04 14:13:30 26 4
gpt4 key购买 nike

enter image description here

hi i am implementing password-reset feature on rest_API using `django_rest_passwordreset` library.but while testing end points its giving the following error:

NoReverseMatch 在/api/accounts/password_reset/reset-password
“password_reset”不是注册的命名空间
please check the code below:


from django.urls import path,include
from account.api.views import SignupApiView
from account.api.views import UserCreationView
from account.api.views import ProfileView,EnableDisableUserView
from rest_framework.authtoken.views import obtain_auth_token



app_name = 'account'

urlpatterns = [
path("signup",SignupApiView.as_view(),name="signup"),
path("create_user",UserCreationView().as_view(),name="create_user"),
path("profile/<int:pk>",ProfileView.as_view(),name="profile"),
path("disable_users/<slug:slug>",EnableDisableUserView.as_view()),
path("disable_users/<int:pk>",EnableDisableUserView.as_view(),name="disable"),
path("login",obtain_auth_token,name="login"),
path('password_reset/', include('django_rest_passwordreset.urls', namespace='password_reset')),#this is where i am getting the error
]

最佳答案

尝试将您的密码重置网址移动到您的主 urls.py 文件

#in main urls.py
...
path('api/password_reset/', include('django_rest_passwordreset.urls', namespace='password_reset')),
...
如果您已经包含 api/urls,您可以只设置 url password_reset/而不使用 api/以避免冲突

关于django - 如何解决此错误 "' password_reset' 不是 rest api django 中的注册命名空间”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62441111/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com