WrappedAttributeError at /docs/
'CSRFCheck' object has no attribute 'process_request'
Request Method: GET
Request URL: http://127.0.0.1:8000/docs/
Django Version: 1.11
Exception Type: WrappedAttributeError
Exception Value:
'CSRFCheck' object has no attribute 'process_request'
Exception Location: D:\Envs\MxShop\lib\site-packages\rest_framework\authentication.py in enforce_csrf, line 140
Python Executable: D:\Envs\MxShop\Scripts\python.exe
Python Version: 3.6.0
Python Path:
['C:\\Users\\huang\\PycharmProjects\\MxShop\\extra_apps',
'C:\\Users\\huang\\PycharmProjects\\MxShop\\apps',
'C:\\Users\\huang\\PycharmProjects\\MxShop',
'C:\\Users\\huang\\PycharmProjects\\MxShop',
'C:\\Program Files\\JetBrains\\PyCharm 2018.2.4\\helpers\\pydev',
'C:\\Users\\huang\\PycharmProjects\\MxShop',
'C:\\Users\\huang\\PycharmProjects\\MxShop\\apps',
'C:\\Users\\huang\\PycharmProjects\\MxShop\\extra_apps',
'C:\\Program Files\\JetBrains\\PyCharm 2018.2.4\\helpers\\pydev',
'C:\\Users\\huang\\.PyCharm2018.2\\system\\cythonExtensions',
'D:\\Envs\\MxShop\\Scripts\\python36.zip',
'C:\\Users\\huang\\AppData\\Local\\Programs\\Python\\Python36\\DLLs',
'C:\\Users\\huang\\AppData\\Local\\Programs\\Python\\Python36\\lib',
'C:\\Users\\huang\\AppData\\Local\\Programs\\Python\\Python36',
'D:\\Envs\\MxShop',
'D:\\Envs\\MxShop\\lib\\site-packages',
'D:\\Envs\\MxShop\\lib\\site-packages\\setuptools-39.1.0-py3.6.egg',
'C:\\Program Files\\JetBrains\\PyCharm '
'2018.2.4\\helpers\\pycharm_matplotlib_backend']
Server time: 星期四, 9 五月 2019 20:57:24 +0800
文档声明Django Rest Framework 可以与Django版本1.11,2.0,2.1一起使用,但是该process_request()方法CSRFCheck实际上是在Django 1.11.6中引入的。
您正在使用的Django版本(1.10.3)对于您的Django Rest Framework版本来说太旧了。
更新 django==1.11.6
---------------------
作者:Christian_yang
来源:CSDN
原文:https://blog.csdn.net/weixin_40744265/article/details/85705138
版权声明:本文为博主原创文章,转载请附上博文链接!
=========================
mixins.UpdateModelMixin
class UpdateModelMixin(object):
"""
Update a model instance.
"""
def update(self, request, *args, **kwargs):
partial = kwargs.pop('partial', False)
instance = self.get_object()
serializer = self.get_serializer(instance, data=request.data, partial=partial)
serializer.is_valid(raise_exception=True)
self.perform_update(serializer)
if getattr(instance, '_prefetched_objects_cache', None):
# If 'prefetch_related' has been applied to a queryset, we need to
# forcibly invalidate the prefetch cache on the instance.
instance._prefetched_objects_cache = {}
return Response(serializer.data)
def perform_update(self, serializer):
serializer.save()
def partial_update(self, request, *args, **kwargs):
kwargs['partial'] = True
return self.update(request, *args, **kwargs)
刷新一下:多了一个 update(更新) 和 partial_update(部分更新)
看一下更新
效果:
D:\VueShop\online-store\src\api\api.js
//修改用户信息
export const updateUserInfo = params => { return axios.patch(`${local_host}/users/1/`, params) }