django - 如何解决此错误“'password_reset' 不是 rest api django 中的注册命名空间”
问题描述
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:
/api/accounts/password_reset/reset-password 'password_reset' 处的 NoReverseMatch 不是已注册的命名空间
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/ url,您可以只使 url password_reset/ 不带 api/ 以避免冲突
推荐阅读
- dart - 如何在飞镖中生成所有字母(大写)的列表?
- sql - Delta Lake 中 SQL 脚本的参数化执行
- wpf - 视频文件块在 Windows 应用程序中录制屏幕时并行上传到服务器
- python - 如何在字典中创建熊猫列值?
- javascript - res.send 没有给出任何回应
- python - 如何从 Deepface detectFace 保存图像?
- javascript - 如何解决请求 URL 问题上可见 API 密钥?
- c# - Livecharts C# Winforms 从 SQL 获取数据
- java - Android:如何在不调整图像大小的情况下以编程方式更改 ImageView 的宽度?
- javascript - 如何使图像的计算框与图像相应地重新缩放?使其完全响应