从查询集中获取正确的数据顺序 python

Getting correct data order from queryset python

我有一个问题,然后当我尝试从查询集中获取特定值时,它按字母顺序给我。 示例:

account_data = Account.objects.all()
[<Account: Merchant: ID: 267 (google@gmail.com), Currency: RUB, Brand: Brand NEWW (google@gmail.com)>,
 <Account: Merchant: ID: 265 (goole@gmail.com), Currency: EUR, Brand: Brand new (google@gmail.com)>,
 <Account: Merchant: ID: 264 (google@gmail.com), Currency: USD, Brand: Brand new2 (google@gmail.com)>,
 <Account: Merchant: ID: 266 (google@gmail.com), Currency: TRY, Brand: Brand new 3 (google@gmail.com)>,
 <Account: Merchant: ID: 269 (google@gmail.com), Currency: BGN, Brand: Brand new 4 (google@gmail.com)>]

currency = ', '.join(sorted(list(account_data.values_list('currency__code', flat=True))))
Out[66]: 'BGN, EUR, RUB, TRY, USD'

所有值都会出现此问题,需要将货币连接到特定帐户,而不是随机或字母顺序。

期望的结果:RUB、EUR、USD、TRY、BGN

使用oder_by("pk") 然后你按照创建顺序得到订单