matthiask / 406-comments

Test repository for using https://utteranc.es/ for https://406.ch/
https://406.ch/
0 stars 0 forks source link

writing/customize-the-django-admin-to-differentiate-environments/ #8

Open utterances-bot opened 10 months ago

utterances-bot commented 10 months ago

Customize the Django admin to differentiate environments - Matthias Kestenholz

https://406.ch/writing/customize-the-django-admin-to-differentiate-environments/?utm_campaign=Django%2BNewsletter&utm_medium=email&utm_source=Django_Newsletter_204

wshayes commented 10 months ago

Just a tip for Django from 4.2 on - you need to use html[data-theme="light"], :root instead of just :root for the CSS selector. You also need to use --header-bg as the CSS variable for the banner background color.

wshayes commented 10 months ago

Thanks! This is a great tip! I learned a lot getting this working, and it will help make site mgmt safer.

Might also be helpful to highlight that one needs to add a custom context processor to inject the ENVIRONMENT setting into the admin templates (and all other templates). e.g. https://stackoverflow.com/questions/49761954/how-to-use-a-custom-context-processor and https://docs.djangoproject.com/en/4.2/ref/templates/api/#writing-your-own-context-processors

matthiask commented 10 months ago

@wshayes Thanks, those are excellent points!