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