我有以下错误: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
返回的是模型类,而不是对象。正确的?在
当你在做
^{pr2}$attrName1
实际上是关键字参数,而不是变量。如果需要,可以尝试动态命名字段相关问题 更多 >
编程相关推荐