【发布时间】:2020-11-26 17:55:43
【问题描述】:
我正在尝试编写 wiki 抄袭代码。但是我收到了这个意外错误:Reverse for 'edit' with no arguments not found。尝试了 1 种模式:['edit/(?P[^/]+)$']。所以有重定向它的Python函数的页面。
{% extends "encyclopedia/layout.html" %}
{% block title %}
Encyclopedia
{% endblock %}
{% block body %}
<form method=POST action="{% url 'edit' %}">
{% csrf_token %}
<label>The Title Of Your Wiki Page</label>
<input type="text" name="Title" value="None">
<label>The Content Of Your Wiki Page</label>
<input type="text" name="Content" value="None">
<input type="submit" value="Submit Your Wiki Page" value="None">
</form>
{% endblock %}
还有我的 Python 函数:
def edit(request):
print(page)
return render(request,"encyclopedia/edit.html")
urls.py中的路径函数:
path("edit/<str:page>", views.edit, name="edit")
重定向到编辑功能的 wiki.html 页面:
{% extends "encyclopedia/layout.html" %}
{% 块标题 %} 百科全书 {% endblock %}
{% block body %}
{{content|safe}}
<form action="/edit/{{name}}" method="POST">
{% csrf_token %}
<input type="submit" value="Edit">
</form>
{% endblock %}
【问题讨论】:
-
您需要共享呈现此处给出的 html 代码的视图代码。
标签: python html django django-templates