Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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
Python Django表格:NoReverseMatch_Python_Django_Web_Django Forms - Fatal编程技术网

Python Django表格:NoReverseMatch

Python Django表格:NoReverseMatch,python,django,web,django-forms,Python,Django,Web,Django Forms,获取错误:找不到“post_new”的NoReverseMatch:Reverse“post_new”不是有效的视图函数或模式名称 base.html中的我的表单: > <form action="{% url 'post_new' %}" method="post"> > {% csrf_token %} > Name:<br> > <input type="text" name="name"><br&g

获取错误:找不到“post_new”的NoReverseMatch:Reverse“post_new”不是有效的视图函数或模式名称

base.html中的我的表单:

> <form action="{% url 'post_new' %}" method="post">
>     {% csrf_token %}
>     Name:<br>
>     <input type="text" name="name"><br>
>     Text:<br>
>     <input type="text" name="text">
>     <input type="submit" value="Submit"> 
  </form>
URL.py:

urlpatterns = [
    url(r'^$', views.base),
    url(r'^post_new/$', views.post_new, name='post_new'),
]

在Django项目中,似乎有一个名为
blog
的应用程序。假设是这样,您需要使用名称空间。在主
urls.py
文件中,应该有如下内容:

urlpatterns = [
    url(r'^blog/', include('blog.urls', namespace="blog")),
]
您可以在
博客
应用程序下的
urls.py
中保持
urlpatterns
相同。使用此名称空间集,您可以通过执行以下操作来引用模板中的
post_new
视图:

<form action="{% url 'blog:post_new' %}" method="post">


这将在
blog
应用程序中查找名为
post\u new
的视图

如果将
action=“{%url”post_new“%}”
替换为
action=“.”“
,会发生什么情况?
<form action="{% url 'blog:post_new' %}" method="post">