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)
将返回BLUEPAY
或HEARTLAND
或1STPAYMENT
。但我希望__str__(self)
返回第一笔付款, Bluepay付款或 HeartLand付款。
请给我解决方案。感谢。
答案 0 :(得分:10)
def __str__(self):
return self.get_paymentmethod_display()