我有以下错误:Cannot resolve keyword 'attrName1' into field. Choices are: codesectrepmodel, configCons, id
。我的代码:
modelName1="ConfigConsModel"
model1 = get_model('actsInformationRetrieval', modelName1)
print "model attr", model1._meta.get_all_field_names() #displays ['codesectrepmodel', 'configCons', 'id']
print "attrName1", attrName1 #displays configCons
print "attr1", attr1 #displays ECOFIN
attr1Instance=model1.objects.get(attrName1=attr1)
怎么了?我认为问题在于get_model
返回模型类,而不是对象。正确的?