Q:

Changing entire background color of table cell in Django Admin

I'm trying to color an entire Django Table Cell and this following code only colorizes the text in the Django Admin and not the ENTIRE table cell.  What is currently looks like:

Here's the current code
class Student(models. Model):

    def city_and_zip(self):
        if self.city_zip:
            cell_html = '<div style = "background-color:#e6f2ff;">%s</div>'
        else:
            cell_html = '<div>%s</div>'

        return cell_html % self.city_zip

    city_and_zip.allow_tags = True

Again, it colorizes it properly... but only to some extent.  I would like to color the entire cell.  Changing div to th doesn't work either

A:

When you declare list_display for modelAdmin, td element wich consist this field has css-class like field-'list_display_name'.  I your case it will field-city_and_zip. 
So you can add css selectors for this class.  Django provides many solutions for this approach.  Here is one:  
class StudentAdmin(admin. ModelAdmin):

    @property
    def media(self):
        media = super(ProductAdmin, self).media
        css = {
            "all": (
                "css/your.css",
            )
        }
        media.add_css(css)
        return media 

In other hand you can write class Media in your admin model:  
class StudentAdmin(admin. ModelAdmin):

    class Media:
        css = {"all":("css/your.css",)}

Then put this css file in your static path and write selectors:  
.field-city_and_zip {
     background-color: #e6f2ff;
}

And it should work like you need.  Also you can put css directly in admin base template
more information about admin page

