Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.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 HttpResponseForbidden在未调用view函数的情况下引发_Python_Django_Http - Fatal编程技术网

Python Django HttpResponseForbidden在未调用view函数的情况下引发

Python Django HttpResponseForbidden在未调用view函数的情况下引发,python,django,http,Python,Django,Http,我正在写一个django服务器。出现了一个非常奇怪的情况——当我尝试测试它时,我将POST发送到其中一个url,只命中了process\u request中间件,而process\u view和对应于该url的view函数都未命中。进程在中间停止,一个 http 403 返回到客户端。另外,使用相同的url(和相同的查看功能),我在另一次使用的是GETit,并且过程顺利进行,没有错误报告。所有其他视图函数/url都可以正常工作 服务器有点大,所以我不打算在这里全部展示;然而,我只有两个定制的中间

我正在写一个django服务器。出现了一个非常奇怪的情况——当我尝试测试它时,我将
POST
发送到其中一个url,只命中了
process\u request
中间件,而
process\u view
和对应于该url的view函数都未命中。进程在中间停止,一个<代码> http 403 <代码>返回到客户端。另外,使用相同的url(和相同的查看功能),我在另一次使用的是
GET
it,并且过程顺利进行,没有错误报告。所有其他视图函数/url都可以正常工作

服务器有点大,所以我不打算在这里全部展示;然而,我只有两个定制的
中间件--
处理请求
处理视图
,正如我所说,只有
处理请求
被称为;它不会返回HttpResponseForbidden

以下是已安装的
中间件

'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'ttam_container.ttam.middlewares.authentication.Authentication'
以下是已安装的应用程序:

'django_concurrent_test_server',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'ttam_container.ttam',
'ttam_container.ui'

知道可能会出现什么问题吗?

可能是因为您忘记在请求中包含csrf令牌。 如果您使用html表单,请在其中包含csrf_标记

<form ...
    {% csrf_token %}
    ...

能否显示您的
视图
模板
?它不是html表单,因此没有
模板
。。。