django+Python的项目中出现 "detail": "CSRF Failed: CSRF cookie not set."
2017-12-14 20:50
465 查看
解决办法:(对django整体项目的目录要了解)
在自己的app下找一个.py(我在app目录下新建一个test.py)文件, 写入:
class DisableCSRF(object):
def process_request(self, request):
setattr(request, '_dont_enforce_csrf_checks', True)
在项目整体的setting.py中的
MIDDLEWARE_CLASSES = ('app.tests.DisableCSRF',)
加入即可。(注意逗号)
在自己的app下找一个.py(我在app目录下新建一个test.py)文件, 写入:
class DisableCSRF(object):
def process_request(self, request):
setattr(request, '_dont_enforce_csrf_checks', True)
在项目整体的setting.py中的
MIDDLEWARE_CLASSES = ('app.tests.DisableCSRF',)
加入即可。(注意逗号)
相关文章推荐
- 关于python 的django-forbidden-csrf-cookie-not-set问题
- python django-forbidden-csrf-cookie-not-set问题
- 微信中打开Django网页提交表单提示403 csrftoken cookie not set问题解决
- 真机上运行项目时,出现Could not launch "FeedMeWorms" failed to get the task for process 3118
- maven项目中,添加依赖后,出现"Dependency 'xxxx‘ not found"解决过程
- 在Eclipse中运行C++程序出现"Launchfailed. Binary not foud"和"Program file notSpecified"的问题
- c++求教:我在linux下用CodeLite编译调试时出现&"warning: GDB: Failed to set controlling terminal: Operation not permitted/n"
- django错误 - Reason given for failure: CSRF cookie not set.
- django错误 - Reason given for failure: CSRF cookie not set.
- python 使用django post提交时出现 CSRF verification failed. Request aborted.
- 在Eclipse中运行C++程序出现"Launch failed. Binary not foud"和"Program file not Specified"的问题
- iOS_Xcode7.0_真机调试出现"Could not find Developer Disk Image"
- ubuntu安装apache2出现"Config variable ${APACHE_LOCK_DIR} is not defined"问题的解决方法
- 新建或者导入项目出现"building gradle project info"一直卡住的解决方法
- 【随笔记录】python 处理中文时出现的错误'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)" 解决方法
- Wordpress转移数据表后出现"You do not have sufficient permissions to access this page"的解决方法
- Ubuntu安装eclipse和pydev成功后,新建项目输入项目名的时候出现"Project interpreter not specified"的错误
- 在IAR 中出现the stack plug-in failed to set a breakpoint on "main"
- Python Django Forbidden (403) CSRF verification failed. Request aborted.
- Ext.data.proxy.Rest提交至*.ashx时出现"HTTP Error 405.0 - Method not allowed" 解决方法