如果键值在该列表中,我想从对象列表中获取一个项目。我正在使用 Django。
attributesValues = AttributeValue.objects.filter(feature__pk = feature_id)
for key, value in request.POST.iteritems():
if key in attributesValues.attribute.name:
## here i'd like to get the matching item and name it attributeValue and give it a new value
attributeValue.value = value
attributeValue.save()
else:
#here the key is not in the list attributesValues so I'll create a new object
return HttpResponse("")