1
嗨,我是使用燒瓶mongoengine這裏是我的模型如何mongoengine stringfield返回選擇值
class Change(db.Document):
code = (('CAD', 'Dolar Canadiense'),
('GBP', 'Libra Esterlina'),
('MXN', 'Peso Mexicano'),
('CHF', 'Franco Suiso'),
('EUR', 'Euro'),
('DKK', 'Corona Danesa'),
('SEK', 'Corona Sueka'),
('JPY', 'Yen Japones'),
('CUP', 'Peso Cubano'),
('PAB', 'Balboa Panama'),
('AUD', 'Dolar Australiano'),
('USD', 'Dolar Estadounidense'),
('NOK', 'Corona Noruega'))
fecha = db.DateTimeField(required = True, unique_with = 'moneda')
moneda = db.StringField(max_length=3, choices=code, required = True)
recanje = db.FloatField(required = True)
canje = db.FloatField(required = True)
@db.queryset_manager
def objects(doc_cls, queryset):
return queryset.order_by('date')
我怎樣才能去選擇的值當我使查詢:
moneda = Exchange.objects.distinct("moneda")
回報:
['Dolar Canadiense','Libra Esterlina'...]