django admin 中的密码重置功能不起作用

发布于 2025-01-16 05:45:59 字数 1951 浏览 2 评论 0原文

urls.py

from django.contrib import admin
from django.urls import path,include
from django.urls import re_path
from App.views import *
from.router import router
from django.views.generic import TemplateView
from rest_framework_simplejwt.views import ( TokenObtainPairView,TokenRefreshView)
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.auth import views as auth_views


urlpatterns = [
    path('', TemplateView.as_view(template_name="social_app/index.html")), #social_app/index.html
    path('admin/', admin.site.urls),         #admin api
    path('api/',include(router.urls)),          #api
    path('accounts/', include('allauth.urls')),       #allauth
    re_path('rest-auth/', include('rest_auth.urls')),    #rest_auth
    path('api-auth/', include('rest_framework.urls')),
    re_path('/registration/', include('rest_auth.registration.urls')),
    path('api/token/', MyObtainTokenPairView.as_view(), name='token_obtain_pair'),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('jobview/',job),
    path('timelog/',timelogview),
    path('chaining/', include('smart_selects.urls')),
    path('admin/password_reset/',auth_views.PasswordResetView.as_view(),name='admin_password_reset',),
    path('admin/password_reset/done/',auth_views.PasswordResetDoneView.as_view(),name='password_reset_done',),
    path('reset/<uidb64>/<token>/',auth_views.PasswordResetConfirmView.as_view(),name='password_reset_confirm',),
    path('reset/done/',auth_views.PasswordResetCompleteView.as_view(),name='password_reset_complete',),
    
    

]  + static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)

我在管理页面登录中提供了密码重置功能,它显示为“忘记密码或用户名?”在页面中,但是当我单击它时,网址将 http://127.0.0.1:8000/admin/login/?next=/admin/password_reset/ 更改为此,但正在加载相同的登录页面没有重定向到任何其他重置页面。

我已尝试但无法解决此问题,请帮助我解决此问题。

urls.py

from django.contrib import admin
from django.urls import path,include
from django.urls import re_path
from App.views import *
from.router import router
from django.views.generic import TemplateView
from rest_framework_simplejwt.views import ( TokenObtainPairView,TokenRefreshView)
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.auth import views as auth_views


urlpatterns = [
    path('', TemplateView.as_view(template_name="social_app/index.html")), #social_app/index.html
    path('admin/', admin.site.urls),         #admin api
    path('api/',include(router.urls)),          #api
    path('accounts/', include('allauth.urls')),       #allauth
    re_path('rest-auth/', include('rest_auth.urls')),    #rest_auth
    path('api-auth/', include('rest_framework.urls')),
    re_path('/registration/', include('rest_auth.registration.urls')),
    path('api/token/', MyObtainTokenPairView.as_view(), name='token_obtain_pair'),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('jobview/',job),
    path('timelog/',timelogview),
    path('chaining/', include('smart_selects.urls')),
    path('admin/password_reset/',auth_views.PasswordResetView.as_view(),name='admin_password_reset',),
    path('admin/password_reset/done/',auth_views.PasswordResetDoneView.as_view(),name='password_reset_done',),
    path('reset/<uidb64>/<token>/',auth_views.PasswordResetConfirmView.as_view(),name='password_reset_confirm',),
    path('reset/done/',auth_views.PasswordResetCompleteView.as_view(),name='password_reset_complete',),
    
    

]  + static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)

I have given the password reset function in the admin page login, it is showing as "Forgotten your password or username?" in the page but when I click it the url changes http://127.0.0.1:8000/admin/login/?next=/admin/password_reset/ to this but the same login page is loading i didnt redirected to any other reset page.

I have tried but couldn't able to fix it, kindly help me to fix this issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城之時有危險 2025-01-23 05:45:59
  1. path('admin/', admin.site.网址)

  2. 然后将这行代码添加到您的 admin.py 文件中并运行服务器并与您的管理员帐户连接,然后转到站点模型并编辑域example.comhttp://127.0.0.1:8000 当您正在开发中(在生产中它将是您的服务器链接)并使用您想要的网站名称编辑名称 example.com

     from django.contrib.sites.models import Site
     从 django.contrib 导入 admin
    
     @admin.注册(网站)
     类 SiteAdmin(admin.ModelAdmin):
     list_display = ('域名', '名称')
     search_fields = ('域名', '名称')
    
  1. Add all urls with admin before path('admin/', admin.site.urls)

  2. Then add this line of code in your admin.py file and run the server and connect with your admin account then go to Site model and edit domain example.com with http://127.0.0.1:8000 when you're in development (in production it will be your server link) and edit name example.com with whatever name you want for your site.

     from django.contrib.sites.models import Site
     from django.contrib import admin
    
     @admin.register(Site)
     class SiteAdmin(admin.ModelAdmin):
     list_display = ('domain', 'name')
     search_fields = ('domain', 'name')
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文