我在我的应用程序中添加了django.contrib.auth身份验证视图。现在,我无法访问这些视图。我收到上面标题中提到的错误。我必须删除名称空间还是将名称空间更改为其他名称?
urls.py:
from django.contrib.auth import views as auth_views
from django.conf.urls import url,include
from . import views
app_name = 'set_goals'
urlpatterns = [
url(r'^$',views.index,name='index'),
url(r'^(?P<pk>[0-9]+)/about/$',views.about,name='about'),
url(r'^(?P<pk>[0-9]+)/download/$', views.download, name='download'),
url(r'^login_user/$', views.login_user, name='login_user'),
url(r'^logout_user/$', views.logout_user, name='logout_user'),
url(r'^register/$', views.register, name='register'),
url('r^password_change/$',auth_views.password_change,{'post_change_redirect':'set_goals:password_change_done'},name='password_change')
,
url('r^password_change/done/$',auth_views.password_change_done,name='password_change_done'),
]
base.html:
{% if user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{% url 'set_goals:about' user.id %}">All Goals</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'set_goals:password_change' %}">Change Password</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'set_goals:logout_user' %}">Logout ({{user.username}})</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'set_goals:index' %}">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'set_goals:login_user' %}">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'set_goals:register' %}">SignUp</a>
</li>
{% endif %}
这是什么错误?在这里要做什么更改?请帮忙。预先感谢!
错误StackTrace:
NoReverseMatch at /
Reverse for 'password_change' with no arguments not found. 1 pattern(s) tried: ['r^password_change/$']
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 2.0.7
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'password_change' with no arguments not found. 1 pattern(s) tried: ['r^password_change/$']
Exception Location: C:\Users\Akhil\PycharmProjects\GoalsProject\goals_env\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 636
Python Executable: C:\Users\Akhil\PycharmProjects\GoalsProject\goals_env\Scripts\python.exe
Python Version: 3.6.5
Python Path:
['C:\\Users\\Akhil\\PycharmProjects\\GoalsProject\\GoalsProject',
'C:\\Users\\Akhil\\AppData\\Local\\Programs\\Python\\Python36',
'F:\\models',
'F:\\models\\research',
'F:\\models\\research\\slim',
'F:\\models\\research\\object_detection',
'C:\\Users\\Akhil\\PycharmProjects\\GoalsProject\\GoalsProject',
'C:\\Users\\Akhil\\PycharmProjects\\GoalsProject\\goals_env\\Scripts\\python36.zip',
'C:\\Users\\Akhil\\PycharmProjects\\GoalsProject\\goals_env\\DLLs',
'C:\\Users\\Akhil\\PycharmProjects\\GoalsProject\\goals_env\\lib',
'C:\\Users\\Akhil\\PycharmProjects\\GoalsProject\\goals_env\\Scripts',
'C:\\Users\\Akhil\\AppData\\Local\\Programs\\Python\\Python36\\Lib',
'C:\\Users\\Akhil\\AppData\\Local\\Programs\\Python\\Python36\\DLLs',
'C:\\Users\\Akhil\\PycharmProjects\\GoalsProject\\goals_env',
'C:\\Users\\Akhil\\PycharmProjects\\GoalsProject\\goals_env\\lib\\site-packages']
Server time: Fri, 3 Aug 2018 02:53:23 +0000
base.html中具有password_change视图的行显示为错误。
答案 0 :(得分:2)
您有错字:
url('r^password_change/$',
r 必须放在单引号之前>
url(r'^password_change/$',
答案 1 :(得分:2)
我认为您的网址格式有误, 试试这个
Sub changeConnection()
Dim pTable As Variant
Dim sheet As Variant
Dim workBookName As String
workBookName = "filename.xlsm"
For Each sheet In Workbooks(workBookName).Worksheets
For Each pTable In sheet.PivotTables
pTable.changeConnection Workbooks(workBookName ).Connections("connection name")
Next pTable
Next sheet
End Sub