TypeError: object() takes no parameters
2018-02-01 21:05
701 查看
Django==2.0.1
python==3.5.2
开启uwsgi是出现上述错误,查阅发现在django==1.11.0中不能获取request.user的返回值,因为不返回,所以继承MiddlewareMixin可以解决此问题.
修改代码如下:
python==3.5.2
import sys from django.views.debug import technical_500_response class ExceptionMiddleware(object): # 此处继承object def process_exception(self, request, exception): if request.user.is_superuser: return technical_500_response(request, *sys.exc_info())
开启uwsgi是出现上述错误,查阅发现在django==1.11.0中不能获取request.user的返回值,因为不返回,所以继承MiddlewareMixin可以解决此问题.
修改代码如下:
import sys from django.utils.deprecation import MiddlewareMixin from django.views.debug import technical_500_response class ExceptionMiddleware(MiddlewareMixin): # 此处继承MiddlewareMixin def process_exception(self, request, exception): if request.user.is_superuser: return technical_500_response(request, *sys.exc_info())
相关文章推荐
- TypeError: object.__new__() takes no parameters
- Python_TypeError:object() takes no parameters
- TypeError: object() takes no parameters
- TypeError: object.__init__() takes no parameters
- TypeError: object() takes no parameters
- TypeError: object() takes no parameters
- python "TypeError: object() takes no parameters"
- Python3问题TypeError: object() takes no parameters
- python报错 TypeError: object() takes no parameters
- __new__方法以及TypeError: object() takes no parameters的处理
- 在Python中TypeError: object() takes no parameters新手问题的解决办法
- TypeError: object() takes no parameters
- IndentationError: unexpected indent,SyntaxError: invalid syntax,TypeError: object() takes no paramet
- Uncaught TypeError: Object #<HTMLCollection> has no method 'toLowerCase'问题
- Uncaught TypeError: Object [object Object] has no method 'live'
- 关于import tensorflow as tf的错误:AttributeError: type object 'NewBase' has no attribute 'is_abstract'
- 【Android】Web Console: Uncaught TypeError: Object [object Object] has no method 'xxx'
- scapy AttributeError: 'NoneType' object has no attribute 'route'解决办法
- python __def__ Exception AttributeError: "'NoneType' object has no attribute
- jquery dialog异常 Uncaught TypeError: Object [object Object] has no method 'dialog'