gpt4 book ai didi

django - Django中字段选择的 “human-readable”值

转载 作者:行者123 更新时间:2023-12-01 07:23:58 25 4
gpt4 key购买 nike

PAYCODE_BLUEPAY = "BLUEPAY"
PAYCODE_HEARTLAND = "HEARTLAND"
PAYCODE_1STPAY = "1STPAYMENT"
PAYCODE_CHOICES =(
(PAYCODE_1STPAY, '1St Payment'),
(PAYCODE_BLUEPAY, 'Bluepay Payment'),
(PAYCODE_HEARTLAND, 'HeartLand Payment'),

)

class Payment(models.Model):
paymentmethod = models.CharField("Payment Method", max_length=20, choices = PAYCODE_CHOICES, blank=False, null=False)

def __str__(self):
return self.paymentmethod

方法 __str__(self)将返回 BLUEPAYHEARTLAND1STPAYMENT .但我要 __str__(self)返回 第一次付款 , 支付宝支付 HeartLand支付 .

请给我解决方案。谢谢。

最佳答案

def __str__(self):
return self.get_paymentmethod_display()

get_FOO_display()

关于django - Django中字段选择的 “human-readable”值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47881817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com