STATUS = (
(1, "Sent"),
(2, "Not send",),)
class Log(models.Model):
status = models.CharField(max_length=255,choices=STATUS)
admin
class LogAdmin(admin.ModelAdmin):
list_display=['status']
This display:
Status - (leer)
How to display Status - Sent or Not send here?
simply use:
class LogAdmin(admin.ModelAdmin):
list_display=['get_status_display']
Django documentation: get_FOO_display
(Updated to django 1.8) the best is to create a function
def get_status(self, obj):
return obj.get_status_display()
get_status.short_description = 'Status'
Put 'get_status' in your list_display and Status it will be the column name in the admin list.
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