from django.apps import apps for o in oids_result: oid_result = snmp.snmpWalk(o.oid) if o.model_filed_name and len(o.model_filed_name) > 0: field_name = o.model_filed_name.get('field_name', '') ''' # 动态反射写法 app_name = o.model_filed_name.get('app_name', '') model_name = o.model_filed_name.get('model_name', '') model_obj = apps.get_model(app_name, model_name) ''' if oid_result and len(oid_result): snmp_result = oid_result[0][1] item.__dict__.update({field_name: snmp_result}) item.save() print("snmp结果", oid_result)
标签:name,oid,snmp,Django,result,filed,model,动态 From: https://www.cnblogs.com/wangcongxing/p/17594379.html