django orm 新增列

from django.db.models import Count, F, Value
from django.db import models

menu_button_list = list(MenuButton.objects.filter(menu=child).annotate(
                isButton=Value(True, output_field=models.BooleanField())).values("id", "name", "value", "isButton"))

 

posted @ 2022-10-19 11:09  汪丛兴  阅读(75)  评论(0编辑  收藏  举报