Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 与#x27相反;编辑';没有找到任何参数。尝试了1种模式:[';文章/编辑/(?P<;pk>;[0-9]+;)/$&]_Django_Python 3.x_Django Forms - Fatal编程技术网

Django 与#x27相反;编辑';没有找到任何参数。尝试了1种模式:[';文章/编辑/(?P<;pk>;[0-9]+;)/$&]

Django 与#x27相反;编辑';没有找到任何参数。尝试了1种模式:[';文章/编辑/(?P<;pk>;[0-9]+;)/$&],django,python-3.x,django-forms,Django,Python 3.x,Django Forms,我是Django的初学者,现在我正在开发一个博客应用程序。在文章编辑部分我被绊倒了,我不知道为什么它会显示这个错误。搜索了很多,找不到答案 NoReverseMatch at /articles/edit/2/ Reverse for 'edit' with no arguments not found. 1 pattern(s) tried: ['articles/edit/(?P<pk>[0-9]+)/$'] article_edit.html {%extends'base

我是Django的初学者,现在我正在开发一个博客应用程序。在文章编辑部分我被绊倒了,我不知道为什么它会显示这个错误。搜索了很多,找不到答案

NoReverseMatch at /articles/edit/2/

Reverse for 'edit' with no arguments not found. 1 pattern(s) tried: ['articles/edit/(?P<pk>[0-9]+)/$']
article_edit.html
{%extends'base_layout.html%}
{%block content%}
{%csrf_令牌%}
编辑文章
{{form.title}}
{{form.slug}}
{{form.thumb}}
{{form.body}}
更新

{%endblock%}
在你的模板文章_edit.html中-帖子url需要一个pk,你需要传递一个pk,就像你在模板my_articles.html中传递pk一样

<div class="create-article"><form class="site-form" action="{% url 'articles:edit' pk=form.instance.pk %}" method="post" enctype="multipart/form-data">{% csrf_token %}...
{%csrf\u令牌%}。。。

这样django就知道你在编辑哪篇文章了

谢谢你,朋友!你救了我的时间!
<div class="create-article"><form class="site-form" action="{% url 'articles:edit' pk=form.instance.pk %}" method="post" enctype="multipart/form-data">{% csrf_token %}...