且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

django模型选择单个字段

更新时间:2023-02-20 18:55:03

Employees.objects.values_list('eng_name', flat=True)

这将创建所有 eng_name s。如果您希望每行不止一个字段,则不能做一个平面列表:这将创建一个元组列表:

That creates a flat list of all eng_names. If you want more than one field per row, you can't do a flat list: this will create a list of tuples:

Employees.objects.values_list('eng_name', 'rank')