R
R
Rodion Yurchenko2015-11-09 10:04:13
Django
Rodion Yurchenko, 2015-11-09 10:04:13

How to change the appearance of the field in the admin panel depending on the content?

Good afternoon
There is a model:

class Landing(models.Model):

    MODERATION = 'MD'
    ACTIVE = 'AC'
    DECLINE = 'DC'
    INACTIVE = 'IN'
    STATUS_CHOICES = (
        (MODERATION, 'MODERATION'),
        (ACTIVE, 'ACTIVE'),
        (DECLINE, 'DECLINE'),
        (INACTIVE, 'INACTIVE')
    )
    status = models.CharField(choices=STATUS_CHOICES, max_length=2, default=MODERATION)

Well, in the admin panel, this field is displayed in the "preview" How can I change the color of the cell, depending on the status?
list_display = ('status')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2015-11-09
@syschel

JavaScript or CSS if it has learned to catch the value of the field.
In general, this is superfluous, this is the jungi admin panel, and not the site admin panel. It is designed for developers, not users.

R
Roman Kitaev, 2015-11-09
@deliro

I have never needed to do this, but I can offer an alternative (and, moreover, subjectively better): list_filter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question