修复docs 文档报错问题

pull/2/head
李强 2021-03-21 20:49:10 +08:00
parent 6526a2da95
commit b41aef6ca0
2 changed files with 13 additions and 8 deletions

View File

@ -33,6 +33,8 @@ class ApiLoggingMiddleware(MiddlewareMixin):
# 请求含有password则用*替换掉(暂时先用于所有接口的password请求参数)
if isinstance(body, dict) and body.get('password', ''):
body['password'] = '*' * len(body['password'])
if not hasattr(response,'data'):
response.data = {}
info = {
'request_ip': getattr(request, 'request_ip', 'unknown'),
'creator': request.user,

View File

@ -181,12 +181,15 @@ def get_verbose_name(queryset=None, view=None, model=None):
:param view:
:return:
"""
if queryset and hasattr(queryset, 'model'):
model = queryset.model
elif view and hasattr(view.get_queryset(), 'model'):
model = view.get_queryset().model
elif view and hasattr(view.get_serializer(), 'Meta') and hasattr(view.get_serializer().Meta, 'model'):
model = view.get_serializer().Meta.model
if model:
return getattr(model, '_meta').verbose_name
try:
if queryset and hasattr(queryset, 'model'):
model = queryset.model
elif view and hasattr(view.get_queryset(), 'model'):
model = view.get_queryset().model
elif view and hasattr(view.get_serializer(), 'Meta') and hasattr(view.get_serializer().Meta, 'model'):
model = view.get_serializer().Meta.model
if model:
return getattr(model, '_meta').verbose_name
except Exception as e:
pass
return ""