Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在用admin进行user和group添加和修改时会出现TypeError #74

Open
Fesbruk opened this issue Jul 26, 2018 · 0 comments
Open

在用admin进行user和group添加和修改时会出现TypeError #74

Fesbruk opened this issue Jul 26, 2018 · 0 comments

Comments

@Fesbruk
Copy link

Fesbruk commented Jul 26, 2018

前端显示:
image
后台报错:
image
主要原因是,在/server/core/TransformMiddleware中对所有request格式进行了转换,所以django自带处理方法中会出现类型错误。我目前的解决办法是加入判断,屏蔽掉来自admin的请求,初步测试可行。

class TransformMiddleware(MiddlewareMixin):
def call(self, request):
"""
Change request body to str type
:param request:
:return:
"""
if isinstance(request.body, bytes):
if not 'admin' in request.path:
data = getattr(request, '_body', request.body)
request._body = data.decode('utf-8')
response = self.get_response(request)
return response

不过这个解决方案只针对了admin,不知道会不会有别的类似的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant