获取objects里面的name字段的所有值的列表:
objects=modelname.objects.filter(id__in=idlist).only('name')
names = [item.name for item in objects]
判断数据是否在已存在:
try:
p = Publisher.objects.get(name='Apress')
except Publisher.DoesNotExist:
print "Apress isn't in the database yet."
else:
print "Apress is in the database."
未完待续