class OrderListAdmin(object):
list_display = ('id','subuser',‘orderuser’,'appname','serverelease','odertype','uplinests','orderappname')
def formfield_for_dbfield(self,db_field, **kwargs,):
if db_field.name == "uplinests":
kwargs['choices'] = (
('remove', '已废弃'),
('Pending', '待审批'),
)
if self.request.user.username == '工单的审批人':
kwargs['choices'] += (('approval', '已审批'),)
return super().formfield_for_dbfield(db_field, **kwargs)
这里要获取当前数据的工单审批人,就是orderuser的值.一直找不到方法。