【发布时间】:2017-11-22 13:20:03
【问题描述】:
我对 Django 和 dicts 有疑问。我只想获得与以下内容匹配的项目。但我无法让它工作。感谢您的帮助。
django_db_query = [{'time': '13:00 Uhr', 'titel': 'test1'}, {'time': '14:00 blah', 'titel': 'test2'}, {'time': '13:00 Uhr', 'titel': 'test3'},]
all_db_items = Django_db.objects.all()
only_13 = dict()
for item in all_db_items:
if item.time is "13":
only_13 += item
想要:我的数据库中的数据结构和多个值在我的字典中,但仅限于 13:00 Uhr 的时间
for item in only_13:
print item.titel
console
test1
test2
【问题讨论】:
-
您能提供给我们您的模型定义吗?
标签: python django dictionary