Django 密码表单未加载

问题描述 投票:0回答:1
Page not found (404)
Request Method: GET
Request URL:    http://127.0.0.1:8000/5/password/
Using the URLconf defined in My_Blog_Project.urls, Django tried these URL patterns, in this order:

admin/
account/
blog/
\[name='index'\]
The current path, 5/password/, didn’t match any of these.

You’re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

views.py

@login_required
def pass_change(request):
    current_user = request.user
    change = False
    form = PasswordChangeForm(current_user)
    if request.method == "POST":
        form = PasswordChangeForm(current_user, data=request.POST)
    if form.is_valid():
        form.save()
    change = True
    return render(
        request,
        "App_Login/pass_change.html",
        context={"form": form, "change": change},
    )

pass_change.html

{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% crispy form %}

{% block title_block %}
    Change Password
{% endblock %}

{% block body_block %}
    {% if change %}
        Password changed successfully.
    {% endif %}
    {% csrf_token %}
    {{ form|crispy }}
    Change Password
{% endblock %}

我的 App_login 应用程序的 url 模式

path('password/',views.pass_change, name='pass_change')

主网址.py

from django.contrib import admin
from django.urls import path, include
from . import views

urlpatterns = [
    path("admin/", admin.site.urls),
    path("account/", include("App_Login.urls")),
    path("blog/", include("App_Blog.urls")),
    path("", views.Index, name="index"),
]

我该如何解决这个问题?

python django
1个回答
0
投票

分享您的 App_login 应用程序的 urls.py

© www.soinside.com 2019 - 2024. All rights reserved.