假如我有代碼如下:from django.contrib.auth.models import User
us = User.objects.all()# 我想要獲取所有用戶的 id,is_activev1 = us.values("id", "is_active")# 現(xiàn)在我想要在結(jié)果里面加入一個(gè)其他字段(原 User 里面沒有),如: other='hehe'# [{"id": 1, "is_active": True, "other": "hehe"}, ...]v1 = us.values("id", "is_active", other="hehe") # 這樣是會(huì)報(bào)錯(cuò)的那么如何實(shí)現(xiàn)我要的結(jié)果呢???希望懂的人幫忙一下。
如何對(duì) django 的 queryset 里面添加一個(gè)固定值的字段???
慕容3067478
2018-07-18 14:22:09