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
The method __str__(self)
will return BLUEPAY
or HEARTLAND
or 1STPAYMENT
. But I want __str__(self)
return 1St Payment, Bluepay Payment or HeartLand Payment.
Please give me solution. Thanks.
def __str__(self):
return self.get_paymentmethod_display()
see get_FOO_display()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With