~ 1 min of reading

Make your django admin (v5) look good with a couple lines of CSS

Your Django admin looks boring, somewhat dated. Mybe your boss asks you to improve it, maybe your wide... It definitly needs of some spice 🌶️. After all, one can only take so much of that blue and yellow.

A pig with lipstick

It would be nice to be able to customize it without having to rely on third party libs or fishy overrides. That's no longer a dream, it's a wish come true.

No more default look, with a couple of CSS lines you can now paint your admin the color of your dreams.

Django admin default look
Django's admin default look. That ugly look!

You can go from that plain look to this:

Django admin default look
Django's admin green look. Definitely better!

Isn't that better? I'm sure you'll enjoy it even more once you saw the little work needed to get there.

As you can see, I painted mine green. But you can paint it any color you want.

What follows is an example to get you started. There are no customizations for the dark theme, but once you copy this code into your project, you can add them yourself.

Add the following code to templates/admin/base.html:

{% extends 'admin/base.html' %} {% block extrahead %} {{ block.super }}
<style>
  :root {
      --mint-green-light: #ADEBB3;
      --mint-green-gray: #9EB8A0;
      --mint-green: #58855C;
      --mint-green-dark: #0D3311;
  }

  input[type="checkbox"] {
      accent-color: var(--mint-green);
  }

  html[data-theme="light"],
  :root {
      --font-family-primary:
          Roboto,
          "Helvetica Neue",
          Arial,
          "Segoe UI",
          system-ui,
          sans-serif,
          "Apple Color Emoji",
          "Segoe UI Emoji",
          "Segoe UI Symbol",
          "Noto Color Emoji";
      --secondary: rgb(20, 30, 20);
      --accent:var(--mint-green-light);
      --header-color: var(--accent);
      --primary: var(--mint-green);
      --link-fg: var(--mint-green-dark);
      --link-hover-color: var(--mint-green);
      --breadcrumbs-fg: var(--mint-green-light);
      --breadcrumbs-bg: rgb(30, 40, 30);
      --selected-row: var(--mint-green-light);
      --button-bg: var(--mint-green-gray);
      --default-button-bg: var(--mint-green);
      --button-hover-bg: var(--mint-green-dark);
      --default-button-hover-bg: var(--mint-green-dark);
  }

  {% comment %} You can add other customizations for the dark theme below {% endcomment %}
  @media (prefers-color-scheme: dark) {
      :root {
      }
  }

  html[data-theme="dark"] {

  }
</style>

{% endblock %}

By the way, I write about software development, web development, and Django. If you liked this post and were wondering how to get more... Join my inner circle (aka newsletter) in easy (and fast!) 4 steps.

  1. Fill your email.
  2. Fill your name (but only if you want).
  3. Smash the button. As hard as you can.
  4. There is no 4th step.

Add your name to join my inner circle (also known as newsletter 💌)

And that's a wrap. I hope you like it (I really do). If you did, hit one of those share buttons and spread it on your socials.