fix(all): 修复创建资源时,created_by字段长度限制导致创建失败的问题

pull/4330/head
Bai 2020-07-15 11:33:47 +08:00 committed by 老广
parent 0f70f5eccf
commit c0f3a1f64a
1 changed files with 4 additions and 1 deletions

View File

@ -43,4 +43,7 @@ def on_create_set_created_by(sender, instance=None, **kwargs):
return
if hasattr(instance, 'created_by') and not instance.created_by:
if current_request and current_request.user.is_authenticated:
instance.created_by = current_request.user.name
user_name = current_request.user.name
if isinstance(user_name, str):
user_name = user_name[:30]
instance.created_by = user_name